Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created October 1, 2015 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/bba30699914d3913de38 to your computer and use it in GitHub Desktop.
Save ruprict/bba30699914d3913de38 to your computer and use it in GitHub Desktop.
/* @flow */
import cookie from 'declarative-cookie';
import {createAction} from 'redux-actions'
import fetch from 'declarative-fetch'
import bind from 'bind-effect'
import {
AUTH_GUEST_SUCCESS,
AUTH_GUEST_FAILURE,
} from '../constants/ActionTypes';
export function loginGuest(): RequestAction {
return bind(fetch(`${process.env.AUTH_API_URL}account/guest`, {method: 'POST'}), token => {
console.log(token);
cookie("token", token.token);
authGuestSuccess(token);
}, err => {
console.log("Fail adsdda " +err );
authGuestFailure(err);
});
};
const authGuestSuccess = createAction(AUTH_GUEST_SUCCESS);
const authGuestFailure = createAction(AUTH_GUEST_FAILURE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment