Skip to content

Commit

Permalink
BUGFIX: Prevent json encode error
Browse files Browse the repository at this point in the history
  • Loading branch information
markusguenther committed Jan 8, 2024
1 parent 187fb5c commit 930e62f
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,29 @@ const fetchCommands = async (endPoint: string): Promise<{ success: boolean; resu
'Content-Type': 'application/json',
},
}))
.then((response: Response) => response && response.json())
.then((response: Response) => {
if (!response.ok) {
return {
success: false,
result: [],
};
}

return (
response &&
response
.json()
.then((data: CommandList) => {
return data;
})
.catch((error: Error) => {
return {
success: false,
result: [],
};
})
);
})
.catch((error: Error) => {
logToConsole('error', error.message);
return {
Expand Down

0 comments on commit 930e62f

Please sign in to comment.