0

How to make encodeURI query parameters?

I'm trying to pass an array with parameters using encodeURI, but [object, object] is missing

await request.get(
  `/api/v1/endpoint?fields=${encodeURI([
     { field: 'reserve_id', value: reserve_id },
     { field: 'in_reserve', value: in_reserve },
  ])}`,
)

enter image description here

request: http://server.com/api/v1/endpoint?fields=%5Bobject%20Object%5D,%5Bobject%20Object%5D

reactchel
  • 51
  • 1
  • 6
  • 1
    What do you expect this code to produce and why? Have you consulted the documentation about what [`encodeURI`](http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) does? – deceze Jan 24 '22 at 13:25
  • **Warning**: the [request module](https://www.npmjs.com/package/request) has been deprecated and should not be used. – Quentin Jan 24 '22 at 13:26

0 Answers0