请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

3回答

CocoIloveu 2023-03-12 21:46:24

https://img1.sycdn.imooc.com//szimg/640dd76909e857a007150195.jpg

我也是出现了相同的情况,是要把getPostDate(req)放在get函数里面,变成链式调用,不然就是同步的,会造成数据的丢失,就会报错

0 回复 有任何疑惑可以回复我~
双越 2019-08-14 21:31:27

看下你 src\router\user.js:32:18 这行,以及其上下文的代码,截图贴出来。

0 回复 有任何疑惑可以回复我~
双越 2019-08-14 19:20:37

具体哪一行报错?

(提醒一下,再提问的时候,尽量把所有报错信息都写上,更多信息有助于更快的定位问题)

0 回复 有任何疑惑可以回复我~
  • 提问者 言戊戌 #1
    > cross-env NODE_ENV=dev nodemon ./bin/www.js
    
    [nodemon] 1.19.1
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching: *.*
    [nodemon] starting `node ./bin/www.js`
    req.sessionId 1565780724588_0.8694839660240226
    user组件的req.session是 undefined
    (node:3804) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'username' of undefined
        at handleUserRouter (E:\node\blog\src\router\user.js:32:18)
        at getPostData.then.postData (E:\node\blog\app.js:140:22)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    (node:3804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:3804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    回复 有任何疑惑可以回复我~ 2019-08-14 19:32:10
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信