I'm making an API request in a method in my React component and want to pass that data as props. My original attempt was to get the API data in this method, return it, and then pass the return value. That was this:
<Window selectionData={this.parseWindowData(selection)}>
And the handler was:
function parseWindowData = selection => {
const url = this.state.apiResults.filter(resultObj => resultObj.name === selection)[0].url
return axios.get(url).then(res => res.data
I tried it both with and without 'return'. Without return, it was undefined. Fine. WITH return, I got this:
I so why is the prop a resolved promise rather than just the PromiseValue? It's the right object and everything. Very confused.