Skip to content

Commit

Permalink
Getting a Token from the Backend for Sign-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch-sriram committed Sep 4, 2020
1 parent f2bfe3b commit 57771e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ Dependency Installation: **`npm i --save redux-thunk`**

1. Adding an `<Auth />` Container Form: [Commit Details](https://github.com/Ch-sriram/burger-builder/commit/48acdef930355784a90ba1487187663e2055a487)
2. Adding **`ACTION Creators`** for the Auth Form: [Commit Details](https://github.com/Ch-sriram/burger-builder/commit/0a75199f9f50f0ba10fa05489739b6541152f27c)
3. Getting a Token from the Backend for Sign-up: [Commit Details]()
20 changes: 20 additions & 0 deletions src/store/actions/auth.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// LIBRARY IMPORTS
import axios from 'axios';

// CUSTOM COMPONENTS
import * as actionTypes from './actionTypes';

export const authStart = () => ({ type: actionTypes.AUTH_START, });
Expand All @@ -18,4 +22,20 @@ export const authFail = error => {

export const auth = (email, password) => dispatch => {
dispatch(authStart());
const authData = {
email,
password,
returnSecureToken: true,
};
axios
.post('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyBCsIqRpXyn4Y3eYRikUd9uhe71UOq-NMA', authData)
.then(res => {
console.log(res);
dispatch(authSuccess(res.data));
return res;
})
.catch(err => {
console.log(err);
dispatch(authFail(err));
});
}

0 comments on commit 57771e2

Please sign in to comment.