Where to set responseType to http GET for HttpClient in angular

前端 未结 1 659
猫巷女王i
猫巷女王i 2020-12-12 05:13

I have a service that makes an http call to my backend:

exportSubs(param: Param): Observable {
    return this.http.get(
      `${e         


        
相关标签:
1条回答
  • 2020-12-12 05:33

    You can specify that the data to be returned is not a JSON using the responseType. See the Requesting non JSON data

    In your example, you should be able to use:

    return this.http.get(
        `${environment.apiBaseUrl}/blah`, { responseType: 'text' })
    

    EDIT

    You can set the responseType as blob,

    return this.http.get(`${environment.apiBaseUrl}/blah`, { responseType: 'blob' });
    
    0 讨论(0)
提交回复
热议问题