diff --git a/lib/Adaptor.js b/lib/Adaptor.js index 415ac3a..b054c3c 100644 --- a/lib/Adaptor.js +++ b/lib/Adaptor.js @@ -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)) }); }); }; diff --git a/package.json b/package.json index d936e9f..f77a41d 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/Adaptor.js b/src/Adaptor.js index 842985c..4637c83 100644 --- a/src/Adaptor.js +++ b/src/Adaptor.js @@ -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 ] } })