Skip to content

Commit

Permalink
Merge pull request #5 from alphauslabs/chore/handle-error-while-fetch…
Browse files Browse the repository at this point in the history
…-url

handle error while fetching url
  • Loading branch information
henry0hai authored Sep 28, 2023
2 parents c832596 + 5282afd commit 32e5052
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
node_modules
dist
dist/*
38 changes: 32 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ export const parseGrpcData = async (
headers,
body: requestObject.body && JSON.stringify(requestObject.body),
}).catch((e: any) => {
onError?.(e);
if (showDebug) {
console.error("Error in fetch: ", e);
}
return onError?.(e);
});

if (res.status != 200) {
return onError?.({
status: res.status,
message: res.statusText,
});
}

const handleLimiterData = (item: any, parsedChunkData: DynamicObject[], allData: DynamicObject[], limiterData: DynamicObject[], limiter: number, concatData: boolean): void => {
const parsedChunk = JSON.parse(item);
const pushedData = objectPrefix ? parsedChunk[objectPrefix] : parsedChunk;
Expand Down

0 comments on commit 32e5052

Please sign in to comment.