5

I'm having tough time figuring out why this is happening, but essentially Redux Promise was working fine for me while returning something like:

    return {
      type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST,
      payload: request
    }

However, I now need to pass another information with it like so

    return {
     order: 0, // New field
     type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST,
     payload: request
    }

This results in an unresolved promise instead of data. I tried renaming order to something like position or index... still nothing.

4

1 回答 1

7

您应该使用metaRedux Promise 所需的字段。Redux Promise 使用 Flux 标准操作 (FSA),它使用以下代码验证操作:

import isPlainObject from 'lodash.isplainobject';

const validKeys = [
  'type',
  'payload',
  'error',
  'meta'
];

function isValidKey(key) {
  return validKeys.indexOf(key) > -1;
}

export function isFSA(action) {
  return (
    isPlainObject(action) &&
    typeof action.type !== 'undefined' &&
    Object.keys(action).every(isValidKey)
  );
}

export function isError(action) {
  return action.error === true;
}

如您所见,有效键只有四个保留字。因此,您应该将 order 属性添加到“有效负载”或“元”中。

于 2016-02-12T12:02:01.173 回答