Skip to content

Commit

Permalink
axios config
Browse files Browse the repository at this point in the history
  • Loading branch information
SummySumanth committed Jan 22, 2019
1 parent ab14838 commit 32fd03a
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
14 changes: 11 additions & 3 deletions view/js/actions/signupPage/signupPageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import signupPageActionTypes from './signupPageActionTypes';
import { AuthActions } from '../auth/auth';
import history from '../../routes/history';
import {signup} from '../../services/signup/signup'
import tokenVC from '../../services/tokenValidityChecker/tokenValidityChecker';

import AxiosConfig from '../../config/axiosServices';

const singupPageActions = {
usernameInputHandler : payload => ({type: signupPageActionTypes.USERNAME_INPUT, payload}),
passwordInputHandler : payload => ({type: signupPageActionTypes.PASSWORD_INPUT, payload}),
submit: payload => (dispatch) => {
signup(payload).then(response => {
dispatch(AuthActions.tokenReceived(response));
history.push(response.redirect);
console.log('axios config is : ', AxiosConfig);
tokenVC().then(response => {
console.log('tokennnnnn response', response);
});
// signup(payload).then(response => {
// dispatch(AuthActions.tokenReceived(response));
// history.push(response.redirect);
// });
}
}

Expand Down
2 changes: 1 addition & 1 deletion view/js/components/landingPage/signinContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Signin extends Component{
<input type="button" value='Back'/>
</Link>

<Link to={this.props.location.pathname + '/signup'}>
<Link to={'signup'}>
<input type="button" value='Sign up'/>
</Link>
</div>
Expand Down
6 changes: 3 additions & 3 deletions view/js/components/landingPage/signupContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Signup extends Component{
<input type="password" placeholder='password' onChange={(e)=>this.props.dispatch(signupPageActions.passwordInputHandler(e.target.value))}/>
</div>
<div className='lnf-LPcard-content-body-signin-local-submit'>
<input type="button" value='Sign in' onClick={()=>this.submitHandler()} />
<input type="button" value='Sign up' onClick={()=>this.submitHandler()} />
</div>
</div>
</div>
Expand All @@ -36,8 +36,8 @@ class Signup extends Component{
<input type="button" value='Back'/>
</Link>

<Link to="signup">
<input type="button" value='Signup'/>
<Link to="signin">
<input type="button" value='Signin'/>
</Link>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions view/js/config/axiosServices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let token = localStorage.getItem('JWT_TOKEN');

const config = {
headers: {"Authorization": `${token}`}
}

export default config;
17 changes: 17 additions & 0 deletions view/js/services/signin/signin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {raiseStatus} from '../../scripts/https';
import axios from 'axios';
const signin = (payload) => fetch('/api/signup',{
method: 'POST',
headers:{
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(raiseStatus);
// .catch(err=>{
// console.log('error was found at service,', err);
// });

export {
signup
}
23 changes: 23 additions & 0 deletions view/js/services/tokenValidityChecker/tokenValidityChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {raiseStatus} from '../../scripts/https';
import axios from 'axios';
import axiosConfig from '../../config/axiosServices';

const tokenVC = () => axios.get('/api/authorized',axiosConfig).then(res=>{
console.log('validity checker response', res);
});



const signin = (payload) => fetch('/api/signup',{
method: 'POST',
headers:{
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(raiseStatus);
// .catch(err=>{
// console.log('error was found at service,', err);
// });

export default tokenVC;

0 comments on commit 32fd03a

Please sign in to comment.