How to pass an array within a query string in HttpClient?

前端 未结 11 1112
面向向阳花
面向向阳花 2021-02-02 09:03

This is my array of actors:

[\'Elvis\', \'Jane\', \'Frances\']

How to pass this array within a query strin

11条回答
  •  别跟我提以往
    2021-02-02 09:31

    Here is a simple way to do it:

    this.http.get(url, { 
        params: ['Elvis', 'Jane', 'Frances'].reduce((accumulator, name) => accumulator.append('names', name), new HttpParams())
    });
    

提交回复
热议问题