Last active
May 22, 2022 21:09
-
-
Save blitzblade/79beef238ae0e2b21d49109e3d2bade3 to your computer and use it in GitHub Desktop.
#medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import './App.css'; | |
function App() { | |
const API_URL = "http://localhost:5000" | |
const initTwitterAuth = () => { //new | |
axios.request({ //new | |
method: "post", //new | |
url: `${API_URL}/api/auth_twitter`, //new | |
data: {callback_url: "http://localhost:3000/twitter_auth_callback"} //new | |
}).then((response) => { //new | |
const { data } = response; //new | |
window.location.href = data.redirect_url; //new | |
}).catch((error) => { //new | |
console.log(error); //new | |
}); //new | |
} //new | |
return ( | |
<div className="App"> | |
<div style={{paddingTop: "400px"}}> | |
<button onClick={initTwitterAuth}>Connect To Twitter</button> {/*new*/} | |
</div> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment