Why does my editor (PHPStorm) say that I'm not gonna need 'await'? It works normally...
Here's the code:
export const fetchBoards = (): AppThunk =>
async function (dispatch): Promise<void> {
try {
const { boards }: { boards: IBoardItem[] } = await api.get('/board');
dispatch({ type: 'UPDATE_BOARDS', payload: boards });
window.console.log('Success');
} catch (e) {
window.console.error(e);
dispatch({ type: 'ERROR', payload: e });
}
};
export const addBoard = (board: { title: string }): AppThunk =>
async function (dispatch): Promise<void> {
try {
const res = await api.post('/board', board);
window.console.log(res);
window.console.log('Before');
await dispatch(fetchBoards()); // 'await' has no effect on the type of this expression
window.console.log('After');
} catch (e) {
window.console.error(e);
const res = dispatch({ type: 'ERROR', payload: e });
}
};