Skip to content

How to make an API request

Stephen Morrison edited this page Feb 26, 2016 · 1 revision

General form

req.App.api.method(endpoint, data, (err, statusCode, body) => {
     // send response here stuff here
});

How to make a API GET request

Example get request with no query parameters to /login

req.App.api.get('/login', (err, statusCode, body) => {
     // send response here stuff here
});

Example get request with query parameters

req.App.api.get('/login', {name: 'John'}, (err, statusCode, body) => {
     // send response here stuff here
});

How to make a API POST request

Example post request to '/login' with no body

req.App.api.post('/login', (err, statusCode, body) => {
     // send response here stuff here
});

Example post request with a body

req.App.api.post('/login', {name: 'John'}, (err, statusCode, body) => {
     // send response here stuff here
});

How to make a API PUT request

Example put request to '/login' with no body

req.App.api.put('/login', (err, statusCode, body) => {
     // send response here stuff here
});

Example put request with a body

req.App.api.put('/login', {name: 'John'}, (err, statusCode, body) => {
     // send response here stuff here
});

Clone this wiki locally