Angular 6: How to set response type as text while making http call

后端 未结 6 1042
無奈伤痛
無奈伤痛 2020-11-28 09:05

I trying to make http request to the spring rest API.. API returns a string value (\"success\" or \"fail\")... but I dont know how to set the response type as string value w

6条回答
  •  鱼传尺愫
    2020-11-28 09:53

    By Default angular return responseType as Json, but we can configure below types according to your requirement.

    responseType: 'arraybuffer'|'blob'|'json'|'text'
    

    Ex:

    this.http.post(
        'http://localhost:8080/order/addtocart', 
        { dealerId: 13, createdBy: "-1", productId, quantity }, 
        { headers, responseType: 'text'});
    

提交回复
热议问题