egg-redis不支持await吗?
发布于 2 年前 作者 dryqiao 2568 次浏览 来自 问答
let aa = await this.app.redis.set(userId,token)

用await就跑不起来,去掉await打印出来是个peomise对象

Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined,
  _trace:
   { Error
    at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (c:\Users\qiao\Desktop\git\egg-club\node_modules\.3.5.1@bluebird\js\release\debuggability.js:400:19)
    at Promise._resolveFromExecutor (c:\Users\qiao\Desktop\git\egg-club\node_modules\.3.5.1@bluebird\js\release\promise.js:480:10)
    at new Promise (c:\Users\qiao\Desktop\git\egg-club\node_modules\.3.5.1@bluebird\js\release\promise.js:79:10)
    at Command.initPromise (c:\Users\qiao\Desktop\git\egg-club\node_modules\.2.5.0@ioredis\lib\command.js:63:18)
    at new Command (c:\Users\qiao\Desktop\git\egg-club\node_modules\.2.5.0@ioredis\lib\command.js:51:8)
    at Redis.get (c:\Users\qiao\Desktop\git\egg-club\node_modules\.2.5.0@ioredis\lib\commander.js:131:29)
    at service.users.compare.then.res (c:\Users\qiao\Desktop\git\egg-club\app\service\session.js:21:41)
    at <anonymous>
     _parent: undefined,
     _promisesCreated: 0,
     _length: 1,
     _promiseCreated: null } }
	 ```
2 回复

支持,请提供最小可复现代码库

目测 外面的方法上没加 async

回到顶部