0

I want to export contents from a function to a jsx file. Here's the code displayed in the console Promise { <pending> } and in the jsx file it shows an error,I don't know where is the problem, Error screenshot

Result of the jsx file

 var  foo=   allBucketKeys(s3, "mymplifyroject-20190123180140-deployment").then(keys => {
     v= [keys[1], keys[2], keys[3]];
    console.log(keys);
  });
  console.log(foo);

  export const listKey= foo;
PrakashG
  • 1,642
  • 5
  • 20
  • 30
  • Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Estus Flask Feb 12 '19 at 12:08
  • 1
    You cannot transform asynchronous code to synchronous. You need to export a promise and chain it in the place where data is consumed. – Estus Flask Feb 12 '19 at 12:10

0 Answers0