I'm trying to do the following.
import axios from 'axios';
function testURL(url) {
var data = axios.post(`http://localhost:4000/api/test`, { url } )
.then(res => {
return res.data;
})
return data
}
It's to be used in React JSX, something like {testURL(props.url)}
. The issue I'm having is that it returns a promise, when really what I need it to do is return the response.
I'm not sure exactly where to put the return statements to get what I'm after. Do I need to make it blocking somehow?