autopilot-sdk
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -54,3 +54,3 @@ 'use strict'; | ||
var request = function () { | ||
var testRequest = function () { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(method, path, _ref) { | ||
@@ -66,3 +66,3 @@ var token = _ref.token, | ||
http = _axios2.default.create({ | ||
baseURL: ENDPOINT, | ||
baseURL: 'https://private-anon-9b8a148517-autopilot.apiary-mock.com/' + VERSION + '/', | ||
headers: { | ||
@@ -88,3 +88,3 @@ 'Content-Type': 'application/json', | ||
return function request(_x, _x2, _x3) { | ||
return function testRequest(_x, _x2, _x3) { | ||
return _ref2.apply(this, arguments); | ||
@@ -94,2 +94,39 @@ }; | ||
var request = function () { | ||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(method, path, _ref3) { | ||
var token = _ref3.token, | ||
options = (0, _objectWithoutProperties3.default)(_ref3, ['token']); | ||
var http, res; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
// create an instance of axios with authentication | ||
http = _axios2.default.create({ | ||
baseURL: ENDPOINT, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
autopilotapikey: token | ||
} | ||
}); | ||
_context2.next = 3; | ||
return http[method](path, options); | ||
case 3: | ||
res = _context2.sent; | ||
return _context2.abrupt('return', res.data); | ||
case 5: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
})); | ||
return function request(_x4, _x5, _x6) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
}(); | ||
var parse = exports.parse = function parse(obj) { | ||
@@ -130,4 +167,5 @@ var keys = (0, _keys2.default)(obj); | ||
exports.default = { | ||
request: request | ||
request: request, | ||
testRequest: testRequest | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -13,3 +13,17 @@ import axios from 'axios'; | ||
const testRequest = async (method, path, { token, ...options }) => { | ||
// create an instance of axios with authentication | ||
const http = axios.create({ | ||
baseURL: `https://private-anon-9b8a148517-autopilot.apiary-mock.com/${VERSION}/`, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
autopilotapikey: token, | ||
}, | ||
}); | ||
const res = await http[method](path, { data: options }); | ||
return res.data; | ||
}; | ||
const request = async (method, path, { token, ...options }) => { | ||
@@ -25,3 +39,3 @@ // create an instance of axios with authentication | ||
const res = await http[method](path, { data: options }); | ||
const res = await http[method](path, options); | ||
return res.data; | ||
@@ -73,2 +87,3 @@ }; | ||
request, | ||
testRequest, | ||
}; |
{ | ||
"name": "autopilot-sdk", | ||
"description": "Node SDK for Autopilot", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Samuel Amoah <sa.am@programmer.net>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
18652
281