Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Component Login pada React
- input(obj)
- {
- var self = this;
- axios.post('http://localhost:3001/Login',
- {
- username: obj.username.value,
- password: obj.password.value
- // Mengirim username dan password ke back-end
- })
- .then((response) => {
- var serverres = response.data;
- if (serverres === 1)
- {
- // artinya sukses login
- // lalu redirect ke component Cart (code di bawah)
- }
- else if (serverres === -1)
- {
- self.setState({
- status: 'Username/Password yang Anda masukkan salah'
- })
- }
- // If-else di atas untuk action dari respon yg didapat dari back-end setelah login
- });
- }
- //================================================================================
- // Component Cart pada React
- componentDidMount = () =>
- {
- // var self = this;
- axios.get('http://localhost:3001/Cart', {
- withCredentials: true
- })
- .then((response) => {});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement