Skip to content

Commit 9f6bc98

Browse files
committed
chore: handle non-2xx as error
1 parent c88b4be commit 9f6bc98

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "revolt-api",
3-
"version": "0.8.6",
3+
"version": "0.8.6-1",
44
"description": "Revolt API Library",
55
"type": "module",
66
"exports": {
@@ -16,7 +16,7 @@
1616
"prepublish": "in-publish && pnpm build || echo Skipping build."
1717
},
1818
"devDependencies": {
19-
"@insertish/oapi": "0.2.4",
19+
"@insertish/oapi": "0.2.5",
2020
"in-publish": "^2.0.1",
2121
"openapi-typescript": "^5.4.2",
2222
"typescript": "^5.8.3"
@@ -29,4 +29,4 @@
2929
"README.md"
3030
],
3131
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
32-
}
32+
}

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function getPathName(anyPath: string) {
3333

3434
const list =
3535
(pathResolve as unknown as Record<string, (string | [string])[]>)[
36-
(segments.length - 1).toString()
36+
(segments.length - 1).toString()
3737
] || [];
3838
for (const entry of list) {
3939
let i = 1;
@@ -204,7 +204,14 @@ export class API {
204204
} as HeadersInit,
205205
body: passbody,
206206
});
207-
return await fetchdata[config?.responseType || "json"]();
207+
208+
const data = await fetchdata[config?.responseType || "json"]();
209+
210+
if (fetchdata.ok) {
211+
return data;
212+
} else {
213+
throw data;
214+
}
208215
}
209216

210217
/**

0 commit comments

Comments
 (0)