react-stickerpipe
Version:
React Component for StickerPipe API
37 lines (29 loc) • 885 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
/* eslint no-console: ["error", { allow: ["error"] }] */
function parseResponse(response) {
var text = void 0;
if (response && response.content && typeof response.content === 'string') {
text = response.content;
}
if (response && response.text && typeof response.text === 'string') {
text = response.text;
}
if (!text) {
console.error('Did not supply any matching response format. Response is:', text);
return null;
}
try {
var parsedResponse = JSON.parse(text);
if (parsedResponse && parsedResponse.data && parsedResponse.data instanceof Object === true) {
return parsedResponse.data;
}
} catch (err) {
console.error('Error while parsing JSON', err);
}
return null;
}
exports.default = parseResponse;
module.exports = exports['default'];
;