separate authenticated endpoints to user.js

This commit is contained in:
Henry Jameson 2026-06-17 14:26:41 +03:00
commit ebf7040662
36 changed files with 1082 additions and 1055 deletions

View file

@ -83,9 +83,11 @@ export const promisedRequest = async ({
...headers,
},
}
if (!formData) {
options.headers['Content-Type'] = 'application/json'
}
if (params) {
url +=
'?' +
@ -112,15 +114,6 @@ export const promisedRequest = async ({
// 204 is "No content", which fails to parse json (as you'd might think)
if (response.ok && response.status === 204) return { _response: response }
if (!response.ok) {
throw new StatusCodeError(
response.status,
json,
{ url, options },
response,
)
}
try {
const json = await response.json()
@ -133,6 +126,15 @@ export const promisedRequest = async ({
json._response = response
if (!response.ok) {
throw new StatusCodeError(
response.status,
json,
{ url, options },
response,
)
}
return json
} catch (error) {
throw new StatusCodeError(