Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = express();
- app.use(function(req, res, next) {
- res.header('Access-Control-Allow-Credentials', true);
- res.header('Access-Control-Allow-Origin', req.headers.origin);
- res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
- res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
- if ('OPTIONS' == req.method) {
- res.send(200);
- } else {
- next();
- }
- });
- export function* login() {
- const username = yield select(makeSelectUsername());
- const password = yield select(makeSelectPassword());
- const requestURL = 'http://myurlhere.com:1337/user/login/';
- const requestOptions = {
- method: 'POST',
- mode: 'cors',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(
- {username: username,
- password: password}
- )
- }
- try {
- const result = yield call(request, requestURL, requestOptions);
- yield put(loginApiCallSuccess(result));
- } catch (err) {
- yield put(loginApiCallFailure(err));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement