Created
January 20, 2018 03:52
-
-
Save navio/2d6f98a67d93c5683524ad45c9bdedbd to your computer and use it in GitHub Desktop.
Fetch Async Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default async (url,method,json) => { | |
if(typeof method !== 'string' ) return fetch(url,fetch); | |
let response = await fetch(url,{ | |
method, | |
headers: { | |
'Accept': 'application/json, text/plain, */*', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify(json) | |
}).then(x=>x.json()); | |
return await response; | |
}; | |
///jsonfetch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment