Issue
chrome is encoding the url. anyone know any solution
Solution
After chatting in the dedicated room you explained to me your need and here is the final solution, which is the simplest you can find :
const params = { 'userId[]': [1, 2, 3] };
const paramStr = Object.entries(params)
.map(([key, value]) => `${key}=${value.join(',')}`)
.join('&');
this.http.get('http://www.test.com?' + paramStr).subscribe();
Working stackblitz (Open the network dev tools)
Other solutions involve rewriting an encoder and providing it to the http module. I'm not a fan of that, when you can just use a one liner to do the same thing.
Answered By - MGX
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.