Skip to content

Instantly share code, notes, and snippets.

@blitzblade
Last active May 22, 2022 21:09
Show Gist options
  • Save blitzblade/79beef238ae0e2b21d49109e3d2bade3 to your computer and use it in GitHub Desktop.
Save blitzblade/79beef238ae0e2b21d49109e3d2bade3 to your computer and use it in GitHub Desktop.
#medium
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