Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self._qs.unescape is not a function #1627

Closed
rouflak opened this issue Jun 3, 2015 · 3 comments
Closed

self._qs.unescape is not a function #1627

rouflak opened this issue Jun 3, 2015 · 3 comments

Comments

@rouflak
Copy link

rouflak commented Jun 3, 2015

I'm trying to execute a POST request with the following code:

request(
    {
        method: "POST",
        data: {
            code: "mycode",
            grant_type: "authorization_code"
        },
        uri: "https://some_identifier:some_secret@my-host-name.com/some/part"
    },
    function(error, response, body) {
        console.log(error, error);
        console.log(response, response);
        console.log(body, body);
    }
);

But I'm having the following error:
Uncaught TypeError: self._qs.unescape is not a function

corresponding to these lines:

// request.js

if (self.uri.auth && !self.hasHeader('authorization')) {
    var uriAuthPieces = self.uri.auth.split(':').map(function(item) {return self._qs.unescape(item)})
    self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true)
}

Maybe I'm doing something wrong but there's something weird with this error.

The _qs attribute of request is an instance of Querystring function localized in ./lib/querystring

Moving to this file I can see the following code:

// ./lib/querystring.js

var qs = require('qs'),
     querystring = require('querystring');

... and then this one

// ./lib/querystring.js

...
Querystring.prototype.unescape = querystring.unescape

When I log in the console the querystring object, I can't find any function called unescape.

Well, I hope I'm not wasting your time with this. Am I misusing the request package or is it really a bug ?

@simov
Copy link
Member

simov commented Jun 3, 2015

@rouflak this might be related to the environment you're using request in, check this issue #1619

@rouflak
Copy link
Author

rouflak commented Jun 3, 2015

Ok, thanks a lot. Closing it as it isn't relevant.

@rouflak rouflak closed this as completed Jun 3, 2015
@stevage
Copy link

stevage commented Jun 18, 2018

I have just run into this as well, bundling an app using Parcel. It's possible that bundlers don't include it because it seems to be deprecated: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape (decodeURI is recommended instead).

lexaboss added a commit to lexaboss/querystring that referenced this issue Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants