Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #56 from OpenFn/55-undefined-log-message
Browse files Browse the repository at this point in the history
Avoid displaying `undefined` value in `create` log message
  • Loading branch information
elias-ba committed Jan 28, 2022
2 parents f94094f + 65cefea commit 45327de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/Adaptor.js
Expand Up @@ -322,7 +322,12 @@ function create(resourceType, data, options = {}, callback = false) {
data: (0, _Utils.nestArray)(data, resourceType),
...requestConfig
}).then(result => {
_Utils.Log.success(`Created ${resourceType}: ${result.headers.location}`);
const {
data
} = result;
const details = `with response ${JSON.stringify(data, null, 2)}`;

_Utils.Log.success(`Created ${resourceType} ${details}`);

return (0, _Utils.handleResponse)(result, state, callback);
});
Expand Down
5 changes: 4 additions & 1 deletion src/Adaptor.js
Expand Up @@ -235,7 +235,10 @@ export function create(resourceType, data, options = {}, callback = false) {
data: nestArray(data, resourceType),
...requestConfig,
}).then(result => {
Log.success(`Created ${resourceType}: ${result.headers.location}`);
const { data } = result;
const details = `with response ${JSON.stringify(data, null, 2)}`;

Log.success(`Created ${resourceType} ${details}`);
return handleResponse(result, state, callback);
});
};
Expand Down
2 changes: 1 addition & 1 deletion test/integration.js
Expand Up @@ -247,7 +247,7 @@ describe('Integration tests', () => {
configuration: {
username: 'admin',
password: 'district',
hostUrl: 'https://play.dhis2.org/2.36.4',
hostUrl: 'https://play.dhis2.org/2.37.2',
},
data: {},
};
Expand Down

0 comments on commit 45327de

Please sign in to comment.