javascript - 如何循环获取从 config.json 文件中获取的大量值
问题描述
我将如何获得一个 for 循环来循环 nodejs 中 config.json 文件中的大量内容。例如
我想要它做什么:
const auth = require("./tokens.json")
//other code here
for tokens in auth {
client.login(token)
}
我的 tokens.json 会像
"Tokens": ["xxxxxx",
"xyxyxx",
"asdasdaf",
"etc"]
解决方案
这将迭代存储在“Tokens”键中的元素:
const auth = require("./tokens.json")
//other code here
auth["Tokens"].forEach((token) => client.login(token));
推荐阅读
- scala - scala.collection.MapView$MapValues 不能转换为 scala.collection.immutable.Map
- python - 为什么我的 python instagram 发布机器人会出现这个错误?
- c++ - Visual Studio 2019,尝试调试,未找到 MSVCP140_APP.dll
- javascript - Electron.js 中的命令行保存文件错误
- discord - Discord.py 使 discord bot 对带有多个表情的消息做出反应
- javascript - 使用 Javascript 准确减去 100 分钟
- json - 如何评估字符串以识别重复键
- sql - 获取Oracle SQL没有记录的天数
- java - @ConditionalOnProperty Bean 配置未按预期工作
- powershell - Windows Defender 和处理下载的 PowerShell 脚本