这个错误意味着什么 - Uncaught TypeError:已经读过了吗? [英] What does this error mean — Uncaught TypeError: Already read?

查看:213
本文介绍了这个错误意味着什么 - Uncaught TypeError:已经读过了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Javascript中,何时抛出此错误?

In Javascript, when is this error thrown?

< img src =https://i.stack.imgur.com/7y3GP.pngalt =在此处输入图像说明>

index.js

/**
 * Created by tushar.mathur on 24/12/15.
 */
'use strict'

const _ = require('lodash')
const Rx = require('rx')
const createDataStore = require('./src/createDataStore')

const fetch = x => Rx.Observable.fromPromise(window.fetch(x)) 
const parseJSON = x => Rx.Observable.fromPromise(x.json()) // Line: 11 (Where the exception is thrown)
var create = _.partial(createDataStore, fetch, parseJSON)
module.exports = {
  create,
  // Alias for legacy purposes
  createDataStore: create,
  createFetchStore: create
}

这是原生承诺错误吗?这意味着什么?谷歌显示没有找到结果。

Is it a native promise error? What does it imply? Google shows no result found.

推荐答案

我认为这意味着已经使用.json()读取了正文。 text()等...当你运行x.json()时,它会获取响应的主体并将其读入JSON。如果您尝试再次运行x.json(),它将为您提供该错误。因此,您只能使用这些方法之一。所以我在你的代码中假设它正在使用一种Body方法再次读取相同响应的主体。

I think it means that the body has already been read by using either .json() .text() etc... When you run x.json() it takes the response's body and reads it into JSON. If you try to run x.json() again it will give you that error. So you could only use one of these methods once. So I am assuming somewhere in your code it is reading the body of the same response again using one of the Body methods.

我认为这就是为什么他们提供 Body.bodyUsed 方法。所以你可以看看它是否已被阅读。

I think that is why they offer the Body.bodyUsed method. So you can see if it has been read already.

这篇关于这个错误意味着什么 - Uncaught TypeError:已经读过了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆