fetchCommentsApi: Relay error messages to the client's 'catch' block.
This commit is contained in:
parent
b2c2096da5
commit
3b1397badc
1 changed files with 6 additions and 1 deletions
|
@ -35,7 +35,12 @@ function fetchCommentsApi(method: string, params: {}) {
|
|||
|
||||
return fetch(url, options)
|
||||
.then((res) => res.json())
|
||||
.then((res) => res.result);
|
||||
.then((res) => {
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message);
|
||||
}
|
||||
return res.result;
|
||||
});
|
||||
}
|
||||
|
||||
export default Comments;
|
||||
|
|
Loading…
Reference in a new issue