Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor the response of a GET request #3223

Closed
FaresKi opened this issue Aug 23, 2020 · 1 comment
Closed

Monitor the response of a GET request #3223

FaresKi opened this issue Aug 23, 2020 · 1 comment

Comments

@FaresKi
Copy link

FaresKi commented Aug 23, 2020

#2562 ## Describe the issue
I want to be able to recursively check the response of a GET Request until my condition is validated.

Example Code

        //Trigger pipelines
        await axios.post(`https://gitlab.com/api/v4/projects/${PROJECT_ID_CREATE}/trigger/pipeline?token=${CREATE_TOKEN}&ref=terraform-v1-mirror`)
            .then(async (gitlabPOSTRequest) => {
                    pipelineId = gitlabPOSTRequest.data.id
                    console.log(`pipeline_id = ${pipelineId}`)
                }, (error) => {
                    console.log(error)
                }
            )

        let config = {
            method: 'GET',
            url: `https://gitlab.com/api/v4/projects/${PROJECT_ID_CREATE}/pipelines/${pipelineId}/jobs?scope[]=success`,
            headers: {
                "PRIVATE-TOKEN": PRIVATE_TOKEN
            }
        }
        //Get Job Id
        await axios(config)
            .then(async (gitlabGETRequest) => {
                    for (let gitlabGETRequestKey in gitlabGETRequest) {
                        if (JSON.stringify(gitlabGETRequest[gitlabGETRequestKey].data.name) == 'apply') {
                            jobId = JSON.stringify(gitlabGETRequest[gitlabGETRequestKey].data.id);
                        } else {
                            return await axios(config);
                        }
                    }
                    console.log(`Job id : ${JSON.stringify(gitlabGETRequest.data[2].id)}`)
                }, (error) => {
                    console.log(error)
                }
            )

Expected behavior, if applicable

I expected it to check again.

Environment

  • Axios Version [latest version]
  • Browser Version [e.g. 22]
  • Node.js Version [e.g. 12.0.1]
  • OS: Linux

Additional context/Screenshots

@github-actions
Copy link
Contributor

Hello! 👋

This issue is being automatically closed because it does not follow the issue template. Please read the issue template carefully and follow all of the instructions when opening a new issue.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant