Redux |未捕获(承诺)TypeError:无法读取属性'数据'未定义的是我的有效载荷

时间:2017-05-23 22:54:04

标签: reactjs redux axios

我收到一个指向我的reducer文件的错误。请求的响应似乎没问题,我记录了响应,这是我得到的:

对象{数据:对象,状态:200,statusText:"确定",标题:对象,配置:对象...} 配置 : 宾语 数据 : 宾语 hasMoreResults : 真正 搜索结果 : 阵列(10) 的 : 宾语 头 : 宾语 请求 : XMLHttpRequest的 状态 : 200 状态文本 : " OK" 的 : 对象

动作档案:

register() {
        hk.hook = hookfunction;
        hk.hooknum = NF_INET_PRE_ROUTING;
        hk.pf = PF_INET;
        hk.priority = NF_IP_PRI_LAST;
}

static unsigned int hookfunction (void *priv,struct sk_buff,const struct nf_hook_state *state) {
        if (skb->sk) {
                printk("%d", skb->sk->sk_mark);
        }
}

Reducer文件

Private Sub Worksheet_Change(ByVal Target As Range)
**' To Select Multiple Items from a Drop Down List in Excel and display the 
' result in different rows for further calculations.** 
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
  If Target.Column = 8 Then
  If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
  Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
      If Oldvalue = "" Then
        Target.Value = Newvalue
      Else
        If InStr(1, Oldvalue, Newvalue) = 0 Then
            ***Target.Value = Oldvalue & Chr(10) & Newvalue***
      Else:
        Target.Value = Oldvalue
      End If
    End If
  End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub

只要我理解我的有效载荷似乎没有被定义,任何人都可以告诉我我做错了什么。但是我在actions文件中获得了有效负载。任何帮助将不胜感激!。

1 个答案:

答案 0 :(得分:-1)

尝试:

import axios from 'axios';
import { FETCH_USERS, FETCH_USER } from './types';

const BASE_URL = "http://api_address/member-search"
export function fetchUsers(id,first_name, last_name, dob) {
  const request = axios.post(${BASE_URL}?patientId=${id}&firstName=${first_name}&lastName=${last_name}&dateOfBirth=${dob}&length=10).then(function (response){
  // put this inside the "})" 
  return {
    type: FETCH_USERS,
    payload: request
  };
  });
}

我相信修复语法错误会有所帮助。否则,函数将在响应返回之前返回,并且request将是未定义的。