I've tried
- initiate - but this result was retrieved from previous result.
- mutate - but I think this is irregular.
Is there any way to use await for a normal get request?
relevant questions:
- Approaches for using RTK-Query hooks inside functions?
- https://www.reddit.com/r/reduxjs/comments/pvvpwy/is_there_a_way_to_await_for_an_rtk_query_response/
Specifically, I want to do the following:
useEffect(() => {
someRTKQuerysGetMethod()
.then(data => setValuesToForm(data))
}, [])
However, the comment I received from phry may have solved the problem.
- I updated to v1.7
- use "useLazyQuery" and unwrap()
const [getPokemon] = useLazyGetPokemonQuery()
useEffect(() => {
getPokemon({...})
.unwrap()
.then(data => setValuesToForm(data))
}, [])
Thank you very much...!!