Sorry if this question is stupid.
This code works correctly. And I just need to export data variable after all promises successfully resolved.
I cannot put t
You should use promise function
promise.js
export function get_data(){
var get_data= new Promise(function(resolve, reject) {
//do your stuff
return resolve('success');
}).catch(function () {
return reject('err');
});
});
//return promise
return get_data;
}
Import
import * as data from './mypromise'
data.get_data().then((reuslt)=>{
console.log(result)})