superagent-jsonp icon indicating copy to clipboard operation
superagent-jsonp copied to clipboard

TypeError: Cannot read property 'push' of undefined

Open manjunatha-d opened this issue 6 years ago • 1 comments

I'm getting this error while using jsonp on node.js

TypeError: Cannot read property 'push' of undefined
    at Request.end ((path_to_project)/node_modules/superagent-jsonp/dist/superagent-jsonp.js:67:15).

On line 36 in the source code, it is trying to push to this._query, which is undefined. I don't see this._query initialised. That's causing issues, may be?

manjunatha-d avatar Jun 17 '18 14:06 manjunatha-d

BTW, This error is thrown only when I'm running this on node.js, it works fine in browser.

Here is my code:

			superagent
				.get(baseUrl + '/rest/v2/me/mini')
				.use(jsonp({
					timeout: 5000
				}))
				.set('Cookie', cookieString)
				.set('Accept', 'application/json')
				.then((res) => {
					resolve(res);
				})
				.catch((error) => {
					resolve('notSigned');
				});

manjunatha-d avatar Jun 17 '18 15:06 manjunatha-d