我想从服务器接收响应。与邮递员一起工作很棒: 请求:
// the default template arguments of MyClass will be used
Wrapper<MyClass<uint8_t, 210>> firstWrapper; // A=uint8_t, B=210, C=size_t, D=true
Wrapper<MyClass<uint8_t, 210, uint8_t>> secondWrapper; // A=uint8_t, B=210, C=uint8_t, D=true
Wrapper<MyClass<uint8_t, 210, uint8_t, false>> thirdWrapper; // A=uint8_t, B=210, C=uint8_t, D=false
响应:
{
"name": "antonio",
"username": "antonio",
"email": "antonio@antonio.pl",
"password": "antonio"
}
我试图在Angular中实现相同的功能,所以我得到了:
{
"success": true,
"message": "User was successfully registered"
}
已检查后端API,效果很好,但仍未出现警报。有什么想法吗?
答案 0 :(得分:0)
如果您将请求作为“ application / json”发送,则不需要JSON.stringify()。我不知道您的后端如何解释它。
this.http.post('http://localhost:8090/api/auth/signup',
{name: name, username: username, password: password, email: email},
{headers: new HttpHeaders({'Content-Type': 'application/json'})})
.subscribe(res => alert(res[0]));