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

Add delay to endpoints(simulate real word) #18

Merged
merged 1 commit into from
Dec 20, 2020
Merged

Add delay to endpoints(simulate real word) #18

merged 1 commit into from
Dec 20, 2020

Conversation

bahmani00
Copy link
Owner

@bahmani00 bahmani00 commented Dec 20, 2020

Creating a sleep func:

const sleep = (ms: number) => 
    (response: AxiosResponse) =>
        new Promise<AxiosResponse>(resolve => setTimeout(() => resolve(response), ms));
const sleepInMs = 500;        

and the usage would be:
get: (url: string) => axios.get(url).then(**sleep(sleepInMs)**).then(responseBody),

@bahmani00 bahmani00 merged commit 7061a6f into main Dec 20, 2020
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

Successfully merging this pull request may close these issues.

None yet

1 participant