Advertisement
awsmpshk

Async request example

Sep 30th, 2021
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const doRequest = async (url) => {
  2.   const response = await fetch(url, {
  3.     headers: {
  4.       Authorization: // ...,
  5.     },
  6.     body: {
  7.       title: 'qweqwe',
  8.       id: 123121,
  9.       // ...
  10.     }
  11.   });
  12.   return await response.json();
  13. };
  14.  
  15. const data = Promise.resolve(doRequest('/api/get/members'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement