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

Retry a http request #67

Open
ghost opened this issue Apr 18, 2019 · 1 comment
Open

Retry a http request #67

ghost opened this issue Apr 18, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 18, 2019

How could i use this to retry http requests.

My http requests are promise based and i like to use async and await.

   public await getResult(sessionId: any, requestId: any) {

        const url = this.config.backendUrl + "/check/report";

        const options = {
            method: "GET",
            uri: url,
            headers: {
                "X-IDCHECK-SESSION-ID": sessionId,
            },
            body: {},
            json: true,
            simple: false,
            resolveWithFullResponse: true,
        };

       return  result = await request(options);
    }

I use the request-promise-native library as my http client. https://github.com/request/request-promise-native

@kevinrambaud
Copy link

You can use a promised version of this library that uses in its core the retry library https://github.com/sindresorhus/p-retry

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