Angular 2 http post params and body

前端 未结 5 2038
暖寄归人
暖寄归人 2021-02-02 16:32

I\'m trying to do an api call from my angular app. What I want to do is send a post request to the api with a command param. I have done a lot of server side testing as well as

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 17:00

    Yes the problem is here. It's related to your syntax.

    Try using this

    return this.http.post(this.BASE_URL, params, options)
      .map(data => this.handleData(data))
      .catch(this.handleError);
    

    instead of

    return this.http.post(this.BASE_URL, params, options)
      .map(this.handleData)
      .catch(this.handleError);
    

    Also, the second parameter is supposed to be the body, not the url params.

提交回复
热议问题