Commit ea6d6756 authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

async login example

parent 56e0f910
import * as types from './actionTypes';
export function login(username, password) {
export function loginold(username, password) {
return {
type: types.LOGIN,
success: password === '42',
};
}
export function login(username, password) {
return (dispatch) => {
return fetch('https://thalia.nu/api/login', {
method: 'POST',
})
.then(
response => response.json())
.then(
(responseJson) => {
console.log(responseJson);
return dispatch(loginold(username, password));
})
.catch(error => console.error(error));
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment