Skip to content

Commit

Permalink
[Fix] Hotfix for handling responses from n-API (#139)
Browse files Browse the repository at this point in the history
Fixes #138
This is a temporary fix until we get rid of the
non-federated deployment option in general
  • Loading branch information
surchs authored Apr 19, 2024
1 parent ac1840d commit c6b0ad7
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,31 @@ function App() {
const url: string = constructQueryURL();
try {
const response = await axios.get(url);
setResult(response.data);
switch (response.data.nodes_response_status) {
case 'partial success': {
response.data.errors.forEach((error: NodeError) => {
enqueueSnackbar(`${error.node_name} failed to respond`, { variant: 'warning' });
});
break;
}
case 'fail': {
enqueueSnackbar('Error: All nodes failed to respond', { variant: 'error' });
break;
}
default: {
break;
// TODO: remove this branch once there is no more non-federation option
if (isFederationAPI) {
setResult(response.data);
switch (response.data.nodes_response_status) {
case 'partial success': {
response.data.errors.forEach((error: NodeError) => {
enqueueSnackbar(`${error.node_name} failed to respond`, { variant: 'warning' });
});
break;
}
case 'fail': {
enqueueSnackbar('Error: All nodes failed to respond', { variant: 'error' });
break;
}
default: {
break;
}
}
} else {
const myResponse = {
responses: response.data,
nodes_response_status: 'success',
errors: [],
};
setResult(myResponse);
}
} catch (error) {
enqueueSnackbar('Failed to retrieve results', { variant: 'error' });
Expand Down

0 comments on commit c6b0ad7

Please sign in to comment.