Open mvarakin opened 2 years ago
Please remove async from the arrow function. If there is no await, async is not required. By returning a Promise (async function call) the method is implicitly async.
Can you provide a PR?
We can remove others functions warnings by changing. https://github.com/jhipster/generator-jhipster/blob/2b98ce8cb2b418ffeb1e4965388d88628767c2b7/generators/entity-client/templates/react/src/main/webapp/app/entities/entity.reducer.ts.ejs#L90-L97 To
async (entity: I<%= entityReactName %>, thunkAPI) => {
const result = await axios.post<I<%= entityReactName %>>(apiUrl, cleanEntity(entity));
<%_ if (!paginationInfiniteScroll) { _%>
thunkAPI.dispatch(getEntities({}));
<%_ } _%>
return result;
I'm considering submitting a PR for this issue, if that's okay? The solution has been almost entirely pointed out by @mshima, so it's not really my contribution, but it has been left unaddressed for a while.
(Creating a test case would require a somewhat forced approach such as checking if the action's content is of the Promise type, so I don't plan to do so.)
Shouldn't axios.get... calls use await prefix?
Currently I have typescript linter errors over all the reducers in getEntities and getEntity "Async arrow function has no 'await' expression."
JHipster version used to create the project is 7.8.1