File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 */
148148export 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
You can’t perform that action at this time.
0 commit comments