【问题标题】:Retrieving data with many jsonp requests使用许多 jsonp 请求检索数据
【发布时间】:2019-06-06 15:22:34
【问题描述】:

我的问题是如何使用许多 jsonp 请求检索数据?实用吗?目前,我在我的 CRA 中使用这段代码(如下)(伪代码)。

import * as fetch from 'fetch-jsonp';
import * as BlueBird from 'bluebird'; // bluebird is promise library

const getData = async () => {
  const urls = ['https://...', 'https://...'] // containt about 20000 urls
  const response = await BlueBird.map(urls, url => fetch(url), { concurrency: 10 })
  return response
}

工作版本的代码在我的 DOM 中创建脚本标签,因此您可以猜到它会延长 DOM 渲染,我的笔记本电脑开始真正发热,我最终收到错误“渲染过程消失”(在小数据上一切正常)。那我该怎么办?将我的代码移动到服务器端并使用 json?或者可以创建单独的反应 dom 并将其用于 jsonp? (不能在客户端使用 json 导致 cors)

【问题讨论】:

    标签: javascript json reactjs jsonp react-dom


    【解决方案1】:

    如果您使用的是 Android 或 java 库,请使用 jsoup 官方依赖项。 然后使用

    String html="here html";
    Document doc=Jsoup.parse(html);
    

    【讨论】:

    • 这似乎与问题无关。您是否将 JSONP 与 Jsoup 混淆了?它们有相似的名字,但完全不同。
    猜你喜欢
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 2019-02-23
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    相关资源
    最近更新 更多