0

My background API is to generate Excel. But when I set parameter passing in Angular, passing parameters in the console does not work. How do I pass parameters for blob-type requests?

ExportMyTicket():Observable<Blob> {
  let params = new HttpParams();

  //Parameter passing failure;
  params.append('myParam', '111');

  return this.http.get<Blob>(`${this.exportExcelUrl}`,
    { params, responseType: 'blob' as 'json' })
}

I tried to pass the parameters on the front end, but I couldn't pass them, no matter how I set the parameters.

1 Answer 1

1

From HttpParams description

This class is immutable; all mutation operations return a new instance.

  1. You should reassign to params with the result returned from .append().

  2. Remove the as: 'json' from responseType: 'blob'.

ExportMyTicket():Observable<Blob> {
  let params = new HttpParams();

  //Parameter passing failure;
  params = params.append('myParam', '111');

  return this.http.get<Blob>(`${this.exportExcelUrl}`,
    { params: params, responseType: 'blob' })
}
Sign up to request clarification or add additional context in comments.

1 Comment

It is my grammar problem. Thank you for your help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.