integreat-adapter-json v1.0.1
JSON adapter for Integreat
Adapter that lets Integreat send and receive content in JSON.
Getting started
Prerequisits
Requires node v8.6 and Integreat v0.7.
Installing and using
Install from npm:
npm install integreat-adapter-json
Example of use:
const integreat = require('integreat')
const jsonAdapter = require('integreat-adapter-json')
const defs = require('./config')
const resources = integreat.mergeResources(integreat.resources(), {
adapters: { json: jsonAdapter() },
})
const great = integreat(defs, resources)
// ... and then dispatch actions as usual
Example source configuration:
{
id: 'store',
adapter: 'json',
endpoints: [
{ options: { uri: 'https://api.com/jsonApi' } }
]
}
Data will be sent with content-type application/json
.
An optional logger may be provided to the jsonAdapter()
function, to log out
the request sent to the service, and its response. The logger must be an object
with an info()
and an error()
function. Both should accept a string message
as first argument, and a meta object as the second.
Available endpoint options:
uri
: The uri to send requests to for this endpoint.baseUri
: An option base uri prepended touri
.headers
: An object of headers to set on the request.method
: Override the http method used to send the request. Default isPUT
when the request has a body, otherwiseGET
.authAsQuery
: Set totrue
to include auth options in query string rather than as request headers. Default isfalse
.retries
: Number of times to retry a request. Default is0
.timeout
: Milliseconds to wait until a request is timed out. Default is120000
.
Running the tests
The tests can be run with npm test
.
Contributing
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests.
License
This project is licensed under the ISC License - see the LICENSE file for details.
3 months ago
6 months ago
9 months ago
10 months ago
10 months ago
12 months ago
1 year ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago