0.1.0 • Published 7 years ago
fettch v0.1.0
fettch
A simple promise fetch/XHR wrapper.
method, url, headers: {}, data: {}
Install
npm i -s fettchimport fettch from 'fettch'or
import fettch from '//unpkg.com/fettch'GET Example
fettch({
url: '//jsonplaceholder.typicode.com/posts'
}).then(response => {
console.log(response)
})POST Example
fettch({
method: 'POST',
url: '/api/auth/signin',
data: {
user,
pass
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})Cheers, Linus