I'm having the following scenario in React:
- I click on a button
- I make an ajax call, I get an url as response
- I want to open that url in a new tab without another click event
Is there a way I can do this in a single click event?
I tried the following code but no success:
return request(options, dispatch)
.then(response => response.data.url ?
(
window.open(response.data.url, '_blank')
) : (
dispatch(updatedPage(id, response.data))
)
);
Cheers!