I want to import an async function from one action to another action in redux
, but it's always throwing this error:
However, if I put it into the same file as the method that's calling the function it's working.
That's my function:
async function getStuff(uid, callback) {
await firebase.database().ref('users/' + uid + '/stuff').once('value')
.then(snapshot => {
callback(snapshot.val());
})
.catch((err) => console.log(err))
}
and that's how I call the function:
await getStuff(uid, async() => {
// some stuff
});
and that's how I import it:
import { getStuff } from './stuff_actions';
you also have to export the function from the file in which you function exists
export async function getStuff(uid, callback) {
await firebase.database().ref('users/' + uid + '/stuff').once('value')
.then(snapshot => {
callback(snapshot.val());
})
.catch((err) => console.log(err))
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.