1.0.4 • Published 5 years ago
Share package Installation $ npm install @i-mart/fetcher
Usage var makeRequest = require('@i-mart/fetcher');
or with ES6-support
import makeRequest from '@i-mart/fetcher';
let dataRequest = makeRequest(requestObject)// returns a promise
dataRequest.then(onResolve(data),onReject(data));
requestObject key value requirement method GET/POST optional(default:GET) url service request mandatory body {} mandatory(for POST) timeout 8000s(default) optional headers object eg.{ "Content-type" : "application/json" } optional ontimeout function(xhr) optional onload function(xhr) optional onerror function(xhr) optional
Resolved Promise-dataRequest:{status:X,statusText:Y,response:Z} status statusText response 100– 199 info NA 200– 299 success JSON-parsed Response 400– 499 client-error NA 500– 599 server-error NA
Rejected Promise-dataRequest:{status:X,statusText:Y,response:Z} status statusText response error some connection error NA service-timeout NA NA