ulvis.paste.net

Paste Search Dynamic
Recent pastes
data
  1. export default async (method, url, payload) => {
  2.   try {
  3.     const config = {
  4.       ...(method !== 'GET' && { body: JSON.stringify(payload) }),
  5.       method: method,
  6.       headers: {
  7.         'Content-Type': 'application/json',
  8.         ...(token && { Bearer: `token` })
  9.       }
  10.     };
  11.  
  12.     const res = await fetch(`${url}`, config);
  13.     const data = await res.json();
  14.     if (!res.ok) throw data;
  15.     return data;
  16.   } catch (error) {
  17.     throw error;
  18.   }
  19. };
Parsed in 0.003 seconds