0

我需要将数据发布到其余 API,但它返回错误 500。当我在 Postman 中测试 API 时,API 正在工作。

邮递员回应

身份验证.service.ts

register(email: string, fullName: string,contactNo: string) {
    var data = {
        'email' : email,
        'fullName' : fullName,
        'contactNo': contactNo
    };

    return this.http.post<any>(`http://localhost:80/user`, {data})
        .pipe(map(user => {

            JSON.stringify(user);
            return user;
        }));
}
4

1 回答 1

3

您正在发布一个具有名为 data 的属性的对象,该属性设置为您的对象数据。从数据周围删除花括号。你的身体看起来像

{
  data: {
    email: email,
    fullName: fullName,
    contactNo: contactNo
  }
}

尝试

register(email: string, fullName: string,contactNo: string) {
    var data = {
        'email' : email,
        'fullName' : fullName,
        'contactNo': contactNo
    };

    return this.http.post<any>(`http://localhost:80/user`, data)
        .pipe(map(user => {

            JSON.stringify(user);
            return user;
        }));
}
于 2018-10-02T04:49:34.023 回答