How to handle an rxjs observable response that could be empty?

前端 未结 1 1399
挽巷
挽巷 2021-01-24 16:14

I\'m using Angular2 and Ionic2 with typescript and would like to handle a response from the backend service where I can get

  • an empty response with http 200
相关标签:
1条回答
  • 2021-01-24 16:32

    Have you tried something like:

    public Update = (itemToUpdate: any): Observable<Response> => {
        return this._http
            .put("htto://localhost/api/", JSON.stringify(itemToUpdate))
            .map(res => res ? res.json() : {});
    }
    
    0 讨论(0)
提交回复
热议问题