insomnia/app/lib/request.js
2016-04-09 14:41:27 -07:00

24 lines
467 B
JavaScript

import networkRequest from 'request'
export default function (request, callback) {
const config = {
url: request.url,
method: request.method
};
if (request.authentication.username) {
config.auth = {
user: request.authentication.username,
pass: request.authentication.password
}
}
if (request.body) {
config.body = request.body;
}
networkRequest(config, function (err, response) {
callback(err, response);
});
}