-1

I need to get information from an api and then call for that information in another page. This is my code, here i wourld look for the information in the api:

enter image description here

And here i would call for it (it's in another file):

enter image description here

I know that fetch is asynchronous but i dont understand it at all, i need to get that information somehow there. Thanks in advance.

ChalsBP
  • 68
  • 2
  • 8
  • The problem here is that fetch is asynchronous, not synchronous. You should either turn the funnction async and wait for the response, or send a callback function as a param for the `buscaAutors` function – Luís Mestre Jan 19 '21 at 17:17

1 Answers1

1

As buscarAutors is async, when you call it as a sync function, it does not way to the fecth result to get the value.

You should await the call to the function an return the fetch (as a promise) in the function.

Santiago Mendoza Ramirez
  • 1,497
  • 2
  • 13
  • 26