Lightweight implementation of fetch api
import fetch from './fetch'
-
fetch(url[, options])
fetch('https://google.com') .then(response => console.log(response)) .catch(error => console.log(error))
Options
method
- http method (default isGET
)decoder
- body decoder (default isJSON.parse
, for none set tonull
)headers
- http headersbody
- http payload (only supported on methods other thanGET
)
Response Object
status
- response status codestatusText
- response status textbody
- decoded or raw body depending ondecoder
settingrawBody
- raw response bodyrequest
- xhr request object