首页 > 解决方案 > 无法在 JavaScript 中获取 40MB 的 JSON 文件

问题描述

我有一个带有 JavaScript 的 Wix 网站,我想导入一个大 (40MB) JSON 文件。

getJsonProducts功能适用​​于较小的文件,但不适用于这种大小的文件。

export async function getJsonProducts() {
    console.log("fetching");
     await getJSON("link")
        .then(json => {
            console.log(json.root.item[1]);
            console.log("end");
        })
        .catch(err => console.log(err));
}

我收到超时错误:

elementory-browser-support.min.js:1 Uncaught (in promise) ExecutionTimeoutError: WebMethod request timed-out after 14 seconds... Did you forget to resolve a promise?
    at FunctionErrorsProvider.getTimeoutError (node_modules/@wix/cloud-runtime-core/lib/providers/FunctionErrorsProvider.js:18:19)
    at timeout.catch.err (node_modules/@wix/cloud-runtime-core/lib/processors/FunctionExecutor.js:20:46)
    at bound (domain.js:396:14)
    at runBound (domain.js:409:12)
    at tryCatcher (node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:121:23)

标签: javascriptvelo

解决方案


推荐阅读