Angular http.post 嵌套 json
Angular http.post nested json
我正在使用带有 FOSUserBundle 的 Angular5 和 Symfony 3.4。
我有类似的东西:
register(username: string, email: string, first: string, second: string)
{
return this.appHttp.post('register', {username, email, first, second}).subscribe(
data => {
this.appHttp.logRequest(data);
}
);
}
我需要发送给 API 的是格式化的 json,例如:
{
"email": "email@test.com",
"username" : "userTest",
"plainPassword" : {
"first" : "123",
"second": "123"
}
}
目前,我的 json 看起来像:
{
"email": "email@test.com",
"username" : "userTest",
"first": "123",
"second": "123",
}
我怎样才能 post 需要 json ?
谢谢!
只需更改:
{username, email, first, second}
到
{username, email, plainPassword : {first, second} }
我正在使用带有 FOSUserBundle 的 Angular5 和 Symfony 3.4。
我有类似的东西:
register(username: string, email: string, first: string, second: string)
{
return this.appHttp.post('register', {username, email, first, second}).subscribe(
data => {
this.appHttp.logRequest(data);
}
);
}
我需要发送给 API 的是格式化的 json,例如:
{
"email": "email@test.com",
"username" : "userTest",
"plainPassword" : {
"first" : "123",
"second": "123"
}
}
目前,我的 json 看起来像:
{
"email": "email@test.com",
"username" : "userTest",
"first": "123",
"second": "123",
}
我怎样才能 post 需要 json ?
谢谢!
只需更改:
{username, email, first, second}
到
{username, email, plainPassword : {first, second} }