当我运行"use strict";
const config = require("./config.json");
const Promise = require("bluebird");
const apiFunctions = require("./api_functions");
module.exports.endpoint = async(event, _) => {
const vrm = event.pathParameters.vrm;
let responseData = await Promise.join(
apiFunctions.getTestData(config),
apiFunctions.getOtherTestData(config),
function(first, second) {
return {first: first, second:second};
}
);
return {
statusCode: 200,
body: JSON.stringify({
data: responseData
})
};
};
//From api_functions
const async = require("async");
const request = require("request");
module.exports = {
getTestData: async function(config) {
const requestFailed = true;
return new Promise(function(resolve, reject) {
async.auto({
todo1: function(callback) {
request("https://jsonplaceholder.typicode.com/todos/1", async.retryable(config.retryLimit, function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, {});
}
}));
},
todo2: ["todo1", async.retryable(config.retryLimit, function(_, callback) {
request("https://jsonplaceholder.typicode.com/todos/1", function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, {});
}
});
})],
todo3: ["todo1", async.retryable(config.retryLimit, function(_, callback) {
request("https://jsonplaceholder.typicode.com/todos/1", function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, error);
}
});
})]
},
function(err, results) {
if (err) {
reject(results);
}
resolve(results);
});
});
},
getOtherTestData: async function(config) {
const requestFailed = true;
return new Promise(function(resolve, reject) {
async.auto({
post1: async.retryable(config.retryLimit, function(callback) {
request(`https://jsonplaceholder.typicode.com/posts`, function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, {});
}
});
}),
post2: ["post1", async.retryable(config.retryLimit, function(_, callback) {
request("https://jsonplaceholder.typicode.com/posts", function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, {});
}
});
})],
post3: ["post1", async.retryable(config.retryLimit, function(_, callback) {
request("https://jsonplaceholder.typicode.com/posts", function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
callback(requestFailed, {});
}
});
})]
},
function(err, results) {
if (err) {
reject(results);
}
resolve(results);
});
});
}
}
时,显示以下错误:
vagrant up
我使用MacOS并运行Vagrant 2.2.4,有人可以帮助我吗?我不是程序员,也不了解Ruby。
答案 0 :(得分:0)
尝试通过以下方法解决此问题: 流浪汉插件卸载hostmanager
$ vagrant.exe plugin uninstall hostmanager
Uninstalling the 'hostmanager' plugin...
Removing hm
Successfully uninstalled hostmanager-1.2.2
Successfully uninstalled rubyhacks-0.1.5