Merge branch 'labday/small-ux-improvement-mike-d' of github.com:Budibase/budibase into labday/small-ux-improvement-mike-d

This commit is contained in:
mike12345567 2024-02-02 16:37:04 +00:00
commit 5257d2cdaa
4 changed files with 14 additions and 18 deletions

@ -1 +1 @@
Subproject commit 52f51dcfb96d3fe58c8cc7a905e7d733f7cd84c2
Subproject commit cc12291732ee902dc832bc7d93cf2086ffdf0cff

@ -1 +1 @@
Subproject commit 4f9616f163039a0eea81319d8e2288340a2ebc79
Subproject commit aaf7101cd1493215155cc8f83124c70d53eb1be4

View File

@ -1,4 +1,4 @@
import fetch from "node-fetch"
import { Response, default as fetch } from "node-fetch"
import env from "../environment"
import { checkSlashesInUrl } from "./index"
import {
@ -40,25 +40,21 @@ export function request(ctx?: Ctx, request?: any) {
}
async function checkResponse(
response: any,
response: Response,
errorMsg: string,
{ ctx }: { ctx?: Ctx } = {}
) {
if (response.status !== 200) {
let error
try {
error = await response.json()
if (!error.message) {
error = JSON.stringify(error)
if (response.status >= 300) {
let responseErrorMessage
if (response.headers.get("content-type")?.includes("json")) {
const error = await response.json()
responseErrorMessage = error.message ?? JSON.stringify(error)
} else {
responseErrorMessage = await response.text()
}
} catch (err) {
error = await response.text()
}
const msg = `Unable to ${errorMsg} - ${
error.message ? error.message : error
}`
const msg = `Unable to ${errorMsg} - ${responseErrorMessage}`
if (ctx) {
ctx.throw(400, msg)
ctx.throw(msg, response.status)
} else {
throw msg
}

View File

@ -63,7 +63,7 @@
"koa-useragent": "^4.1.0",
"lodash": "4.17.21",
"node-fetch": "2.6.7",
"nodemailer": "6.7.2",
"nodemailer": "6.9.9",
"passport-google-oauth": "2.0.0",
"passport-local": "1.0.0",
"pouchdb": "7.3.0",