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

Commit

Permalink
coerce response into result object
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Aug 8, 2016
1 parent efe0f65 commit 8e14341
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/Adaptor.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
});
exports.lastReferenceValue = exports.dataValue = exports.dataPath = exports.merge = exports.sourceValue = exports.fields = exports.field = undefined;

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.execute = execute;
@@ -129,8 +131,9 @@ function fetch(params) {
console.log("Fetching data from URL: " + url);
console.log("Applying query: " + JSON.stringify(query));

return (0, _Client.getThenPost)({ username: username, password: password, query: query, url: url, sendImmediately: sendImmediately, postUrl: postUrl }).then(function (result) {
console.log("Success:", result);
return (0, _Client.getThenPost)({ username: username, password: password, query: query, url: url, sendImmediately: sendImmediately, postUrl: postUrl }).then(function (response) {
console.log("Success:", response);
var result = (typeof response === 'undefined' ? 'undefined' : _typeof(response)) === 'object' ? response : JSON.parse(response);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "language-http",
"version": "0.0.4",
"version": "0.0.5",
"description": "An HTTP Language Pack for OpenFn",
"main": "lib/index.js",
"scripts": {
5 changes: 3 additions & 2 deletions src/Adaptor.js
Original file line number Diff line number Diff line change
@@ -54,8 +54,9 @@ export function fetch(params) {
console.log("Applying query: " + JSON.stringify(query))

return getThenPost({ username, password, query, url, sendImmediately, postUrl })
.then((result) => {
console.log("Success:", result);
.then((response) => {
console.log("Success:", response);
let result = (typeof response === 'object') ? response : JSON.parse(response);
return { ...state, references: [ result, ...state.references ] }
})

0 comments on commit 8e14341

Please sign in to comment.