fetchCommentsApi: Relay error messages to the client's 'catch' block.

This commit is contained in:
infinite-persistence 2021-04-22 16:32:57 +08:00 committed by Thomas Zarebczan
parent b2c2096da5
commit 3b1397badc

View file

@ -35,7 +35,12 @@ function fetchCommentsApi(method: string, params: {}) {
return fetch(url, options) return fetch(url, options)
.then((res) => res.json()) .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; export default Comments;