5

I am trying to perform an API call with superagent but it encodes my api key which gets rejected.

get(url).query({ key: 'Fmjtd%7Cluu').end(function(err, res) {

The key is being sent as

Fmjtd%257Cluu

Any ideas how to prevent this using superagent? If I make it part of the 'url' part it's fine but I would like to pass it as query data if possible.

cyberwombat
  • 38,105
  • 35
  • 175
  • 251

1 Answers1

0

I am not familiar with SuperAgent but here are the options I would take to solve the problem.

  1. Escape the key. Try 'Fmjtd\%7Cluu'

  2. Since it appears SuperAgent is applying "encodeURIComponent" to transform the key to make it safe for http transport, you could "decodeURIComponent" it first before passing it on. However, it is quite possible that this breaks SuperAgent (since they probably have a good reason for encoding the URI components in the first place).

  3. Send in a bug report and have the maintainer create a proper fix instead of the hacks I suggest above

takinola
  • 1,643
  • 1
  • 12
  • 23