Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Facing encoding problem in angular in url

chrome is encoding the url. anyone know any solution

almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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.

almost 4 years ago · Santiago Trujillo Report

0

export class AppComponent {
  codec = new HttpUrlEncodingCodec();
  name = 'Angular';
  baseUrl = 'https://jsonplaceholder.typicode.com/';

  constructor(private http: HttpClient) {
    const params = { 'userId[]': 1 };
    this.http
      .get(this.baseUrl + 'posts', { params })
      .subscribe((data) => {
        this.name = this.name.concat(data[0].title);
      });
  }
}
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!