From f19326528bac0bf4f31a55922912c0967b58ff01 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 25 Oct 2023 00:13:42 +0800 Subject: [PATCH] Fix fetch doesn't throw error when 500 --- src/components/translation-block.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/translation-block.jsx b/src/components/translation-block.jsx index 06ce52de..339d4ca9 100644 --- a/src/components/translation-block.jsx +++ b/src/components/translation-block.jsx @@ -35,7 +35,10 @@ function _lingvaTranslate(text, source, target) { text, )}`, ) - .then((res) => res.json()) + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.json(); + }) .then((res) => { return { provider: 'lingva',