Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (err) {
// probably not JSON, could be an HTML response
const titleContent = /<title>(.+?)<\/title>/.exec(body);
errorMessage = titleContent ? titleContent[1] : 'REST API error';
}
logError({
...logBase,
body: body.length > 512 ? `${body.substr(0, 512)}...` : body,
err: new Error(errorMessage),
context: response, // this will provide limited info - check apiRequest for more detail
});
return;
}
// not an error response - log in dev, not prod
if (process.env.NODE_ENV !== 'production') {
logger.info({
...logBase,
httpRequest: response,
});
}
};
</title>
errorMessage = JSON.stringify(info.errors[0]) || body;
} catch (err) {
// probably not JSON, could be an HTML response
const titleContent = /<title>(.+?)<\/title>/.exec(body);
errorMessage = titleContent ? titleContent[1] : 'REST API error';
}
logError({
...logBase,
body: body.length > 512 ? `${body.substr(0, 512)}...` : body,
err: new Error(errorMessage),
context: response, // this will provide limited info - check apiRequest for more detail
});
return;
}
// not an error response
logger.info({
...logBase,
httpRequest: response,
});
};
</title>
function mapStateToProps(state) {
logger.info(state);
return {
data: (state.api.foo || {}).value,
};
}