1.0.0 • Published 8 years ago
fetchio v1.0.0
Fetchio
Simple wrapper over window.fetch
How to use
Include to project
Global
<script src="node_modules/fetchio/dist/main.bundle.js"></script>
<script>
var fetchio = fetchio.default;
</script>
CommonJS
var fetchio = require('fetchio')['default'];
ES6
import fetchio from 'fetchio'
Usage
const Api = fetchio.Init({
baseUrl: 'https://api.example.com',
requestInterceptor: function (req) {
// do some stuff
return req
},
fetch: {/*...*/}
})
Api.Fetch('users', { headers: {/*...*/} }, { userId: 1 })
// GET https://api.example.com/users?userId=1
// return Promise
Api.Fetch('users', {
method: 'post',
body: JSON.stringify(user)
})
// POST https://api.example.com/users
// return Promise
Dependencies
- whatwg-fetch
- url-join
License
MIT
1.0.0
8 years ago