英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论