mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Merge pull request #347 from jdalrymple/343-error-handling
This commit is contained in:
commit
21c91c3408
@ -35,12 +35,12 @@ function defaultRequest(service: any, { body, query, sudo, method }) {
|
||||
}
|
||||
|
||||
async function processBody(response) {
|
||||
const contentType = response.headers.get('content-type');
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
const content = await response.text();
|
||||
|
||||
if(contentType.includes('json')) {
|
||||
try {
|
||||
return JSON.parse(content || {});
|
||||
return JSON.parse(content || "{}");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user