From d2d73905142b005ffe9559cdd463f942a82e5044 Mon Sep 17 00:00:00 2001 From: xmcp Date: Fri, 10 May 2019 14:18:55 +0800 Subject: [PATCH] fix error json --- src/UserAction.js | 6 +++--- src/flows_api.js | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/UserAction.js b/src/UserAction.js index f8b03687..aad49c99 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -72,7 +72,7 @@ export class LoginForm extends Component { .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } set_token(json.user_token); @@ -226,7 +226,7 @@ export class ReplyForm extends Component { .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } this.setState({ @@ -306,7 +306,7 @@ export class PostForm extends Component { .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } this.setState({ diff --git a/src/flows_api.js b/src/flows_api.js index 6f15ecfc..acd7f6f1 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -19,7 +19,7 @@ export const API={ .then((json)=>{ if(json.code!==0) { if(json.msg) throw new Error(json.msg); - else throw new Error(json); + else throw new Error(JSON.stringify(json)); } json.data=json.data @@ -54,7 +54,7 @@ export const API={ if(json.msg && json.msg==='已经关注过辣') {} else { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } } return json; @@ -77,7 +77,7 @@ export const API={ .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } return json; }); @@ -92,7 +92,7 @@ export const API={ .then((res)=>res.json()) .then((json)=>{ if(json.code!==0) - throw new Error(json); + throw new Error(JSON.stringify(json)); return json; }); }, @@ -108,7 +108,7 @@ export const API={ .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } return json; }); @@ -124,7 +124,7 @@ export const API={ .then((json)=>{ if(json.code!==0) { if(json.msg) throw new Error(json.msg); - else throw new Error(json); + else throw new Error(JSON.stringify(json)); } return json; }); @@ -139,7 +139,7 @@ export const API={ .then((json)=>{ if(json.code!==0) { if(json.msg) alert(json.msg); - throw new Error(json); + throw new Error(JSON.stringify(json)); } return json; });