我正在使用redux-saga从我的React Native应用程序中的简单json服务器获取数据。看起来提取成功,但是我无法提取正在返回的响应对象中寻找的数据。 以下是我的生成器函数中的代码:
requie("//address of the image in your project")
控制台日志打印为:
function* loadOpenItemsSaga(action) {
try {
const response = yield call(fetch, baseUrl + 'thingsList', { method: 'GET'});
console.log('loadOpenItemsSaga successful', response);
yield put({ type: ActionTypes.ACTION_SUCCESS, resp: response });
} catch (error) {
const errorMessage = { code: error.code, message: error.message };
console.log('loadOpenItemsSaga fail', errorMessage);
yield put({ type: ActionTypes.ACTION_FAILURE, error: errorMessage });
}
}
我期望的实际内容是:
10:55:59: loadOpenItemsSaga successful Response {
10:55:59: "_bodyBlob": Blob {
10:55:59: "_data": Object {
10:55:59: "blobId": "eb3d53ce-ecc8-4e48-9f53-1c9b4129d300",
10:55:59: "offset": 0,
10:55:59: "size": 1429,
10:55:59: },
10:55:59: },
10:55:59: "_bodyInit": Blob {
10:55:59: "_data": Object {
10:55:59: "blobId": "eb3d53ce-ecc8-4e48-9f53-1c9b4129d300",
10:55:59: "offset": 0,
10:55:59: "size": 1429,
10:55:59: },
10:55:59: },
10:55:59: "headers": Headers {
10:55:59: "map": Object {
10:55:59: "access-control-allow-credentials": Array [
10:55:59: "true",
10:55:59: ],
10:55:59: "cache-control": Array [
10:55:59: "public, max-age=0",
10:55:59: ],
10:55:59: "connection": Array [
10:55:59: "keep-alive",
10:55:59: ],
10:55:59: "content-type": Array [
10:55:59: "application/json; charset=utf-8",
10:55:59: ],
10:55:59: "date": Array [
10:55:59: "Mon, 20 Aug 2018 05:25:59 GMT",
10:55:59: ],
10:55:59: "etag": Array [
10:55:59: "W/\"595-QGa7N/U2dPsbWUU83//t6RMzYwQ\"",
10:55:59: ],
10:55:59: "expires": Array [
10:55:59: "-1",
10:55:59: ],
10:55:59: "transfer-encoding": Array [
10:55:59: "chunked",
10:55:59: ],
10:55:59: "vary": Array [
10:55:59: "Origin",
10:55:59: ],
10:55:59: "x-content-type-options": Array [
10:55:59: "nosniff",
10:55:59: ],
10:55:59: "x-powered-by": Array [
10:55:59: "Express",
10:55:59: ],
10:55:59: },
10:55:59: },
10:55:59: "ok": true,
10:55:59: "status": 200,
10:55:59: "statusText": undefined,
10:55:59: "type": "default",
10:55:59: "url": "http://localhost:3001/thingsList",
10:55:59: }
如何从Response对象提取数据? response.json()无法正常工作
关于, 拉什米