Logging response.data outputs the HTML I need to display my header however, I can’t find a way to access the response outside the get function. I’m pretty sure I need to find a way to add the data to the state but I can’t get it working.
Any help would be appreciated.
const Header = ({ state }) => {
axios.get('external_url')
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
return (
<>
{/* Where i want to output response.data */}
</>
);
};
export default connect(Header);