Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "redux-nl", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "A GraphQL inspired rest client side network layer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -138,2 +138,15 @@ <p align="center"> | ||
#### Headers | ||
``` | ||
{ | ||
... | ||
meta: { | ||
headers: { | ||
... <--- | ||
} | ||
} | ||
} | ||
``` | ||
## API Spec Example | ||
@@ -169,3 +182,2 @@ | ||
- Only supports a single API connection. | ||
- Only supports single path parameter e.g. `"/{user}/orders/{id}"` would break the module. | ||
- No support for request headers. Although support could be added via a PR by allowing a `headers` key inside the action `meta`. | ||
- Only supports single path parameter e.g. `"/{user}/orders/{id}"` would break the module. |
@@ -9,5 +9,2 @@ /** | ||
// Optional headers. | ||
const headers = {}; | ||
/** | ||
@@ -20,5 +17,6 @@ * Sends a request to the API using Axios | ||
* @param options | ||
* @param headers | ||
* @return {Promise} | ||
*/ | ||
const axios = (base, method, path, options = {}) => { | ||
const axios = (base, method, path, options = {}, headers) => { | ||
const params = { | ||
@@ -43,16 +41,6 @@ method, | ||
const createRequest = { | ||
/** | ||
* Add headers to this request instance. | ||
* | ||
* @param key | ||
* @param value | ||
*/ | ||
addHeader: (key, value) => { | ||
headers[key] = value; | ||
request: (base, method, path, options, headers) => { | ||
return axios(base, method, path, { data: { ...options } }, headers); | ||
}, | ||
request: (base, method, path, options) => { | ||
return axios(base, method, path, { data: { ...options } }); | ||
}, | ||
/** | ||
@@ -67,4 +55,4 @@ * | ||
*/ | ||
get: (base, path, options) => { | ||
return axios(base, "get", path, options); | ||
get: (base, path, options, headers) => { | ||
return axios(base, "get", path, options, headers); | ||
}, | ||
@@ -81,4 +69,4 @@ | ||
*/ | ||
post: (base, path, options) => { | ||
return axios(base, "post", path, { data: { ...options } }); | ||
post: (base, path, options, headers) => { | ||
return axios(base, "post", path, { data: { ...options } }, headers); | ||
}, | ||
@@ -95,4 +83,4 @@ | ||
*/ | ||
patch: (base, path, options) => { | ||
return axios(base, "patch", path, { data: { ...options } }); | ||
patch: (base, path, options, headers) => { | ||
return axios(base, "patch", path, { data: { ...options } }, headers); | ||
}, | ||
@@ -109,4 +97,4 @@ | ||
*/ | ||
destroy: (base, path, options) => { | ||
return axios(base, "delete", path, options); | ||
destroy: (base, path, options, headers) => { | ||
return axios(base, "delete", path, options, headers); | ||
}, | ||
@@ -113,0 +101,0 @@ |
@@ -53,6 +53,6 @@ /** | ||
// ); | ||
// | ||
createRequest | ||
.request(baseUrl, method.toLowerCase(), url, payloadInSnakeCase) | ||
.request(baseUrl, method.toLowerCase(), url, payloadInSnakeCase, meta?.headers) | ||
.then(response => resolve(createRequest.normlzDataResponse(response))) | ||
@@ -62,3 +62,2 @@ .catch(error => reject(error)); | ||
console.log({ requestAction, responseAction, baseUrl, requestPromise }); | ||
return takeLatest(requestAction, action => | ||
@@ -68,4 +67,4 @@ AbstractNetworkSaga(action, baseUrl, requestPromise, responseAction) | ||
}); | ||
console.log({ sagas }) | ||
yield all(sagas); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
181
32436
486