Add form-fetch-action to some forms, fix "fetch action" resp bug (#37305)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
PineBale
2026-04-21 02:58:44 +08:00
committed by GitHub
parent 1d25bb22f4
commit ca44b5fca8
7 changed files with 37 additions and 35 deletions

View File

@@ -91,7 +91,7 @@ async function handleFetchActionSuccess(el: HTMLElement, opt: FetchActionOpts, r
async function handleFetchActionError(resp: Response) {
const isRespJson = resp.headers.get('content-type')?.includes('application/json');
const respText = await resp.text();
const respJson = isRespJson ? JSON.parse(await resp.text()) : null;
const respJson = isRespJson ? JSON.parse(respText) : null;
if (respJson?.errorMessage) {
// the code was quite messy, sometimes the backend uses "err", sometimes it uses "error", and even "user_error"
// but at the moment, as a new approach, we only use "errorMessage" here, backend can use JSONError() to respond.