如何更改Nuxt 3的$fetch超时限制为30秒。

huangapple go评论76阅读模式
英文:

How to change the Nuxt 3 $fetch timeout limit of 30 seconds

问题

似乎 Nuxt 3 的 $fetch 函数有一个30秒的超时限制,我找不到延长它的方法。是否有一种方法可以延长超时限制?

示例:

// server/api/render.ts
...
        var startTime = performance.now();
        try {
            const output = await $fetch(config.MODEL_ENDPOINT_URL + "/render", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    Accept: "application/json",
                },
                body: JSON.stringify(input),
            });
        } catch (error) {
            console.log(error)
            var endTime = performance.now();

            console.log(
                "执行时间:" + (endTime - startTime) / 1000 // 在30秒后精确报错。
            );
        }
...
英文:

It seems like the Nuxt 3 $fetch function has a 30 second timeout and I can't find a way to extend it. Is there a way to extend the timeout limit?

Example:

// server/api/render.ts
...
        var startTime = performance.now();
        try {
            const output = await $fetch(config.MODEL_ENDPOINT_URL + "/render", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    Accept: "application/json",
                },
                body: JSON.stringify(input),
            });
        } catch (error) {
            console.log(error)
            var endTime = performance.now();

            console.log(
                "Execution time: " + (endTime - startTime) / 1000 // Throws error after exactly 30 seconds.
            );
        }
...

答案1

得分: 1

已实现在oFetch 1.2中,并用作timeout选项。Nuxt 3.7正在使用它!

英文:

Is implemented in oFetch 1.2 and use as timeout option. Nuxt 3.7 is using it!

huangapple
  • 本文由 发表于 2023年6月26日 23:21:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76558073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定