【发布时间】:2021-04-21 08:02:02
【问题描述】:
{url: ${api}/products , 方法: ['GET', 'OPTIONS']},
ReferenceError: api 未在 authJwt (C:\Users\abuba\Desktop\BACKEND\helpers\jwt.js:9:22) 中定义
const expressJwt = require('express-jwt');
function authJwt(){
const secret = process.env.secret;
return expressJwt({
secret,
algorithms: ['HS256']
}).unless({
path: [
{url: `${api}/products` , methods: ['GET', 'OPTIONS']},
`${api}/users/login`,
`${api}/users/register`
]
})
}
module.exports = authJwt;
【问题讨论】:
-
一切都在错误信息中。变量/常量
api没有定义,需要定义才能使用。
标签: node.js