1import axios from 'axios';
2
3const { data } = await axios.post('http://localhost:1337/auth/local', {
4 identifier: 'reader@strapi.io',
5 password: 'strapi',
6});
7
8console.log(data);
9
10 Copied to clipboard!
11 1componentDidMount() {
2 const { match: {params: { provider }}, location: { search } } = this.props;
3 const requestURL = `http://localhost:1337/auth/${provider}/callback${search}`;
4
5 request(requestURL, { method: 'GET' })
6 .then((response) => {
7 auth.setToken(response.jwt, true);
8 auth.setUserInfo(response.user, true);
9 this.redirectUser('/');
10 }).catch(err => {
11 console.log(err.response.payload)
12 this.redirectUser('/auth/login');
13 });
14}
15
16redirectUser = (path) => {
17 this.props.history.push(path);
18}