Comparing version 0.3.2 to 0.4.0
{ | ||
"name": "fitch", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "Test using fetch API", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -83,2 +83,6 @@  | ||
raw = true, // return the raw output of fetch() | ||
params: { // transform to '?test1=test-1&test2=test-2' | ||
test1: 'test-1', | ||
test2: 'test-2', | ||
}, | ||
} | ||
@@ -89,2 +93,3 @@ | ||
``` | ||
See more about fetch configuration at: [Fetch API](https://developer.mozilla.org/pt-BR/docs/Web/API/Fetch_API). | ||
@@ -91,0 +96,0 @@ ## Browser Support |
@@ -11,8 +11,9 @@ module.exports = { | ||
) { | ||
let data; | ||
if (body) { | ||
body = JSON.stringify(body); | ||
data = JSON.stringify(body); | ||
} | ||
return { | ||
method, | ||
body, | ||
body: data, | ||
cache, | ||
@@ -19,0 +20,0 @@ headers, |
@@ -5,2 +5,3 @@ require('es6-promise').polyfill(); | ||
const config = require('./config'); | ||
const params = require('./params'); | ||
@@ -29,4 +30,8 @@ module.exports = { | ||
request(method, url, req = {}) { | ||
const params = config.create(method, req); | ||
const call = fetch(url, params); | ||
let paramsEncoded = ''; | ||
if (req.params) { | ||
paramsEncoded = params.transform(req.params); | ||
} | ||
const configObj = config.create(method, req); | ||
const call = fetch(url + paramsEncoded, configObj); | ||
return req.raw ? call : call.then(this.check); | ||
@@ -33,0 +38,0 @@ }, |
Sorry, the diff of this file is not supported yet
14974
12
75
115