我正在使用从for循环接收到的某些引导击中端点。我想将某些引导排除在端点之外。
async function main() {
const url = validateURL(process.argv[2]);
const origin = validatePath(process.argv[3]);
const debug = validateDebug(process.argv[4]);
let guid =
data = await getCategories(url, origin);
result = data["results"];
for (i = 0; i < result.length; i++) {
guid = result[i]["guid"];
await legacyEndpoint(url,guid);
}
}
main();
是否有可能包含我想忽略的Guid列表的文件,所以当循环运行时,它只会留下那些Guid?
谢谢
async function main() {
const url = validateURL(process.argv[2]);
const origin = validatePath(process.argv[3]);
const debug = validateDebug(process.argv[4]);
let guid =
data = await getCategories(url, origin);
result = data["results"];
for (i = 0; i < result.length; i++) {
guid = result[i]["guid"];
if (guid !== "32666424" || "489429571658" || "6803523795" || "489429571658"){
await legacyEndpoint(url,guid);
} else
console.log("excluded");
}
}
答案 0 :(得分:0)
在针对不允许的列表检查GUID时,可以使用Array.includes JavaScript Array includes() Method来确保GUID不在不允许的列表中。
类似的东西
async function main() {
var unallowedGuids = ["32666424","489429571658","6803523795","489429571658"];
const url = validateURL(process.argv[2]);
const origin = validatePath(process.argv[3]);
const debug = validateDebug(process.argv[4]);
var data = await getCategories(url, origin);
var result = data["results"];
for (i = 0; i < result.length; i++) {
let guid = result[i]["guid"];
if (!unallowedGuids.includes(guid)){
await legacyEndpoint(url,guid);
}
else
console.log("excluded");
}
}