shows error message when request req fails

This commit is contained in:
ajaythapliyal
2023-02-22 10:02:05 +05:30
parent 41742dccd3
commit 1fc9d61325
6 changed files with 41 additions and 6 deletions

View File

@@ -38,8 +38,12 @@ export const conversationSlice = createSlice({
type: 'ANSWER',
});
})
.addCase(fetchAnswer.rejected, (state) => {
.addCase(fetchAnswer.rejected, (state, action) => {
state.status = 'failed';
state.conversation.push({
text: 'Something went wrong. Please try again later.',
type: 'ERROR',
});
});
},
});