【发布时间】:2026-01-20 00:35:01
【问题描述】:
我想在 fetch() 函数之后将用户重定向到新网页。我使用 facebook 登录按钮,当用户通过身份验证时,我想将他重定向到包含他的数据的新页面。所以我想知道最好的方法是什么。
我认为 window.location + 一个会话变量可以工作,但我很确定还有比这种方法更正确的方法,比如在 then() 函数之后的重定向函数。
我厌倦了使用 fetch().then().redirect() 但它不起作用,我想做的是类似 ...().redirect(function(userDatas, url){.. .});
//this is inside the facebook connection function
fetch('/connect',options).then(function(response){
response.json().then(function(value){
window.location = 'http://localhost:3000/fight.html';
console.log(value);
});
//after this function, I would like to go to this fight.html page
所以我希望用户在 FB 连接到他的数据后到达fight.html 页面。
【问题讨论】:
标签: javascript node.js