Вы пропускаете await
в funcOne
, когда вы звоните funcTwo
, вы можете опустить await
, если возвращаете значение funcTwo
, но вы не
Так ..
// Call first fucntion inside MainScreen.js
import Fire from '../Fire';
export default class MainScreen extends React.Component {
makeRemoteRequest = async () => {
const res = await Fire.shared.funcOne({ title: "test" });
}
};
// Fire.js
class Fire {
funcOne = async ({title}) => {
// Here you should add await
await this.funcTwo(title);
// or
// return this.funcTwo(title);
};
funcTwo = async (title) => {
// save to database
console.log(title);
};
}
Fire.shared = new Fire();
export default Fire;