Skip to content

Commit 78d5532

Browse files
committed
simplify
1 parent 823f3fc commit 78d5532

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/lib/util/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,19 @@ export type Options = {
146146
* @return {Promise} promise - A promise that resolves to the responseBody or rejects to an error.
147147
*/
148148
export async function makeRequest(options: Options) {
149-
const response = await fetch(options.url)
149+
const { url, errorOnNon200Response } = options
150+
151+
const response = await fetch(url)
150152
const responseBody = await response.text()
151153

152-
if (options.errorOnNon200Response && response.status !== 200) {
154+
if (errorOnNon200Response && response.status !== 200) {
153155
throw new Error(`StatusCode: "${response.status}", ResponseBody: "${responseBody}."`)
154156
}
155157

156158
try {
157-
return parseContent(options.url, responseBody)
159+
return parseContent(url, responseBody)
158160
} catch (error) {
159-
throw new Error(`An error occurred while parsing the file ${options.url}. The error is:\n ${util.inspect(error, { depth: null })}.`)
161+
throw new Error(`An error occurred while parsing the file ${url}. The error is:\n ${util.inspect(error, { depth: null })}.`)
160162
}
161163
}
162164

0 commit comments

Comments
 (0)