Open maze-le opened 5 years ago
That body variable isn't JSON - should be '{ "some": "json" }'
e.g. (in Javascript, not Typescript):
const rp = require('request-promise');
const test = async () => {
try {
const url = 'http://example.com/';
const body = '{ "some": "json" }';
const postReturn = await rp(url, { encoding: 'utf8', body });
return postReturn;
} catch (error) {
console.log('I cannot catch this', error);
}
};
test();
The library seems to trigger a non-catchable, non-recoverable error when using a post-request with a json-body without the option
json: true
.I am not sure if this is the fault of the library or an underlying problem with the nodejs runtime. I am using the library with typescript and the package @types/request-promise