Advertisement
awsmpshk

Async request example

Sep 30th, 2021
719
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
RAW Paste Data Copied
Advertisement