我有一个错误语法错误:JSON.parse:JSON数据的第1行第1列出现意外字符
使用验证器json时,我意识到错误在
let json = JSON.stringify(user);
let params = "json="+json; // here is the error in the "j" of json=
错误:第1行出现分析错误:json = {“名称”:“p ^
json = {
"name": "pedroeoeo",
"surname": "oiuoiuoiu",
"email": "iouoiu@hlkjlkj.com",
"password": "lkjlkjlkj"
}
但是我需要添加到json = {“name”:“kjlklk”...等等...
register(user):Observable<any>
{
let json = JSON.stringify(user);
console.log(json);
let params = "json="+json;
console.log(params);
let headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
return this._http.post(this.url+'register', params, {headers:headers});
}
后端是用laravel做的我用postman测试过了,后端还可以,但是当我添加到一个json变量时,问题是有Angular 的
json={"name":"pedroeoeo","surname":"oiuoiuoiu","email":"iouoiu@hlkjlkj.com","password":"lkjlkjlkj"
```}
I dont know how to fix it
I dont know what can I do to fix the issue
1条答案
按热度按时间r9f1avp51#
正确发送。