Last 2 days, I’ve been trying to create something ‘simple’ but unfortunatelly I couldn’t do it on my own.
Simply I want to create a function that returns me my data, and this function to have a parameter which will allow me to get the data object I want.
This way you should be able to have the response.data value exported into myData. I’m not fully sure about that but the lack of return's makes me suspect ^^
so when using async/await it is just shorthand for using then aka promises. they are doing the same thing so you would not want to use await AND then in the same thing. @DanCouper looks right to me.
in the original example you are exporting a function called myData that takes myElement as a parameter. I am a little confused since myElement isnt directly used by axios, but then again i dont know the use case.
later on your would import {myData} from '....' and the call myData(myElement).
this will return the entire piece of data you are requesting
Just small issue, I know its async function but when I call it straight from my index.js it gives me error, if I call it thru setTimeout function, it returns me what I need, any chance we can fix this?
P.S second issue or question is, can you help me how I can do a loop or map function to return all the names from the Object?