ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.59k stars 1.33k forks source link

Right-hand side of 'instanceof' is not callable #1571

Closed rahulmadaan closed 4 years ago

rahulmadaan commented 4 years ago

(node:17614) UnhandledPromiseRejectionWarning: TypeError: Right-hand side of 'instanceof' is not callable at stringify (/Users/rahulma/interest/slackApps/step-curator/node_modules/superagent/node_modules/qs/lib/stringify.js:75:20) at module.exports (/Users/rahulma/interest/slackApps/step-curator/node_modules/superagent/node_modules/qs/lib/stringify.js:248:27) at Request._end (/Users/rahulma/interest/slackApps/step-curator/node_modules/superagent/lib/node/index.js:976:29) at Request.end (/Users/rahulma/interest/slackApps/step-curator/node_modules/superagent/lib/node/index.js:950:8) at jsonHandler (/Users/rahulma/interest/slackApps/step-curator/routes/mission/index.js:148:8) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:17614) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:17614) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

code :

superagent .post(url) .send({ "content": JSON.stringify(content) "filename": "somefile.txt" }) .set({"Content-Type": "application/x-www-form-urlencoded"}) .set("Authorization", Bearer ${TOKEN}) .accept('application/json') .end((error) => { if (error) throw error; });

JosefButts commented 4 years ago

This problem is lacking some context, such as what you are are passing in as 'context in the JSON.stringify(context). This error would seem to indicate that you possible not passing in anything for context and this is causing an error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/invalid_right_hand_side_instanceof_operand

rahulmadaan commented 4 years ago

I have verified that I am passing value( correct one ) in JSON.stringify(content) but I am still getting the same warning.

niftylettuce commented 4 years ago

This seems to be an issue in the qs package, not our usage, so I'm going to close for now until you can provide a PR with a test that fails with this issue. Thank you.