小编Pib*_*ibo的帖子

Axios(在React-native中)不在localhost中调用服务器

我正在构建一个非常简单的api和react-native应用程序.服务器运行良好(使用PostMan测试)但应用程序不会调用服务器.当axios必须发送帖子请求时它会阻止(见下文).

我很绝望:-(在这里度过太多时间.请,如果你能帮助我...

这是我的代码LogIn页面.它派遣动作创建者(使用redux)给出电子邮件和密码:

...
const LogIn = React.createClass({
  submitLogin() {
    // log in the server
    if (this.props.email !== '' && this.props.psw !== '') {
      if (this.props.valid === true) {
        this.props.dispatch(logIn(this.props.email, this.props.psw));
      } else {
        this.props.dispatch(errorTyping());
      }
    }
  },
...
Run Code Online (Sandbox Code Playgroud)

电子邮件和密码被检索并发送给动作创建者:

import axios from 'axios';
import { SIGNIN_URL, SIGNUP_URL } from '../api';
// import { addAlert } from './alerts';
exports.logIn = (email, password) => {
  return function (dispatch) {    
    console.log(email);
    console.log(password);
    console.log(SIGNIN_URL);
    return axios.post(SIGNIN_URL, { email, password })
    .then(
      (response) => …
Run Code Online (Sandbox Code Playgroud)

node.js react-native axios

13
推荐指数
4
解决办法
2万
查看次数

Immutable.js deleteIn 不起作用

我一直在努力解决这个问题,但可能有一些 Immutable.js 的东西我没有抓住。我希望有人能帮助我理解。

我有一个这样的测试:

import {List, Map} from 'immutable';
import {expect} from 'chai';

import {setInitial,
        addAtListOfMembers,
        removeAtListOfMembers
        } from '../src/core';


      describe('removeAtListOfMembers', () => {

        it('remove a member to the list of members', () => {
          const state = Map({
            removing: 3,
            infos : Map(),
            members: Map({
                1:Map({
                    userName:'René',
                    date:'12/02/2016'
                }),
                2:Map({
                    userName:'Jean',
                    date:'10/03/2016'
                }),
                3:Map({
                    userName:'Elene',
                    date:'05/01/2016'
                })
              })
          });
          const nextState = removeAtListOfMembers(state);

          expect(nextState).to.equal(Map({
            infos : Map(),
            members: Map({
                1:Map({
                    userName:'René',
                    date:'12/02/2016'
                }),
                2:Map({
                    userName:'Jean',
                    date:'10/03/2016'
                })
              })
          })); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs immutable.js redux

3
推荐指数
1
解决办法
4028
查看次数