How do I POST JSON in Angular 2?

后端 未结 3 1374
孤街浪徒
孤街浪徒 2020-12-24 03:00

I don\'t understand what I am doing wrong, my server returns \"undefined\" when I try to get the json.

POST(url, data) {
        var headers = new Headers(),         


        
3条回答
  •  孤城傲影
    2020-12-24 03:40

    You need to stringify the payload

    var requestoptions = new RequestOptions({
                method: RequestMethod.Post,
                url: this.apiURL + url,
                headers: headers,
                body: JSON.stringify(data)
            })
    

提交回复
热议问题