提前感谢您的帮助.
在使用Bluebird承诺时,我有一系列的承诺在运行.在最后一个承诺期间,我想为数组中的每个对象多次运行一个函数.
下面是伪代码:
var userArray = [
{
name: "John",
email: "John@email.com"
},
{
name: "Jane",
email: "jane@email.com"
}];
var functionOne = function() {
//returns Promsie object
};
var functionTwo = function() {
//returns promise object
};
var createUser = function(user) {
return User.findOrCreate({email: user.email},{
name: user.name,
email: user.email
});
};
functionOne()
.then(functionTwo)
.each(createUser(userArray))
.then(function onComplete() {
console.log("Complete");
})
.catch(function onError() {
console.log("Um...it's not working");
});
Run Code Online (Sandbox Code Playgroud)
我知道我没有正确使用每个功能.使用Bluebird实现此目的的正确方法是什么?
您好,提前感谢您的帮助。
我在旧网站上有一个博客,我正在尝试使用 haproxy 将所有帖子重定向到新网站上的新位置 301。例如,我希望 https://www.oldsite.com/john-blog/blogpost1被 301 重定向到https://www.newsite.com/jill-blog/blogpost1。
https://www.oldsite.com/john-blog => https://www.newsite.com/jill-blog
frontend https
option http-server-close
reqadd X-Forwarded-Proto:\ https
acl is_ob path_sub john-blog
redirect location https://www.newsite.com/jill-blog code 301 if is_ob
Run Code Online (Sandbox Code Playgroud)
我已经弄清楚如何转发流量,/john-blog但无法弄清楚如何进行重写,以便/john-blog/blogpost1在旧站点 301s/jill-blog/blogpost1上到新站点。