appeal
v0.1.3
Published
ES6 Component for making requests or appeals.
Downloads
33
Readme
Appeal.js
ES6 Component for making requests or appeals.
import Request from "appeal";
Request.get
.url("https://itunes.apple.com/search?term=appeal")
.header("Content-Type", "application/json")
.header("Custom-Header", "custom value")
.results((error, result) => {
//do somethig... result.body is json automatically, because the content type contains 'json' on it
});
Quality and Compatibility
Every build and release is automatically tested on the following platforms:
No support for browsers yet. If your platform is not listed above, you can test your local environment for compatibility by copying and pasting the following commands into your terminal:
npm install appeal
cd node_modules/appeal
gulp test-local
Installation
Copy and paste the following command into your terminal to install Appeal:
npm install appeal --save
Import / Require
// ES6
import appeal from "appeal";
// ES5
var appeal = require("appeal");
// Require.js
define(["require"] , function (require) {
var appeal = require("appeal");
});
Getting Started
Making requests
Importing Request will return an object with static methods for each one of the http verbs (currently just get, post, put and delete) that will allow you tu chain options until you finally get the results.
import Request from "appeal";
Request.get
.url("https://itunes.apple.com/search?term=appeal")
.header("Content-Type", "application/json")
.header("Custom-Header", "custom value")
.results((error, result) => {
//do somethig... result.body is json automatically, because the content type contains 'json' on it
});
Available methods
Http verbs
- get
- post
- put
- delete
Methods within the chain
url(endpointString)
Where you specifi the resouce url address with the argument <endpointString>.
header(name, value)
With this one you can add headers with <name>'s like Content-Type, or some Custom-One with the appropiate <value>.
data(object)
Used to specify the body being <object> that body to be sent.
results(callback<error, result>)
In the method you pass a callback function to it, which has available two arguments to receive: error, and the result. If there is a content type header specified containing the string json on it, it will try to parse de response to result.body automatically.
How to Contribute
See something that could use improvement? Have a great feature idea? We listen!
You can submit your ideas through our issues system, or make the modifications yourself and submit them to us in the form of a GitHub pull request.
We always aim to be friendly and helpful.
Running Tests
It's easy to run the test suite locally, and highly recommended if you're using Appeal.js on a platform we aren't automatically testing for.
npm test