separate authenticated endpoints to user.js
This commit is contained in:
parent
04a0b0b8a8
commit
ebf7040662
36 changed files with 1082 additions and 1055 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue