我收到错误await只在异步函数中有效。当我拿出文档本身的代码时,我觉得这很奇怪。
为什么会抛出错误?
const OpTrade = require('trade-opskins-api')
const OPSKINS_API_KEY = 'key';
const opTrade = new OpTrade(OPSKINS_API_KEY);
const interface = 'user'; // item | trade | user
const method = 'GetProfile';
// const response = await opTrade.userGetProfile()
// or
const response = await opTrade[interface + method]()
console.log(JSON.stringify(response, null, 2));