Skip to content

Commit c4b7282

Browse files
authored
Copy response data (axios) into body (for backwards compatiblity) (#26)
* copy response data into body for backwards compatiblity * bump version
1 parent 0424411 commit c4b7282

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

lib/Http/Client/RequestClient.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function executeRequest(req, callback) {
6767
context.response = res;
6868
context.response.statusCode =
6969
context.response.statusCode || context.response.status;
70+
context.response.body = res.body || res.data;
7071
const convertedResponse = convertHttpResponse(res);
7172
callback(null, convertedResponse, context);
7273
})
@@ -75,6 +76,7 @@ function executeRequest(req, callback) {
7576
err.response.statusCode =
7677
err.response.statusCode || err.response.status;
7778
context.response = err.response;
79+
context.response.body = err.response.body || err.response.data;
7880

7981
callback(err, convertHttpResponse(err.response), context);
8082
} else {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moesifapi",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Collection/Data Ingestion API for Moesif",
55
"main": "./lib/index.js",
66
"keywords": [

test/ApiControllerTest.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var CampaignModel = require('../lib/Models/CampaignModel');
66
var expect = require('chai').expect;
77
var config = moesifapi.configuration;
88

9-
config.ApplicationId = "Your Moesif ApplicationId";
9+
config.ApplicationId = "Your Moesif Application Id";
1010

1111
describe('TestAddEvent', function() {
1212
it('createEvent() should return 201 HTTP status', function(done) {
@@ -258,6 +258,11 @@ describe('TestGetAppConfig', function() {
258258
it('getAppConfig() should return 200 HTTP status', function(done) {
259259
var controller = moesifapi.ApiController;
260260
var request = controller.getAppConfig(function(error, response, context) {
261+
console.log('response body from context');
262+
console.log(JSON.stringify(context.response.body));
263+
console.log('response body from HTTPResuponse object');
264+
console.log(JSON.stringify(context.response.body));
265+
261266
expect(context.response.statusCode).to.equal(200);
262267
if (error) done(error);
263268
else done();

0 commit comments

Comments
 (0)