1

我正在为我的 Angular 应用程序使用 nebular auth,我想在用户登录到标题时添加令牌这是 API 响应

{
  "status": 0,
  "message": null,
  "data": {
    "type": "bearer",
    "token": "string"
  }
}

在我的 auth.module

NbAuthModule.forRoot({
      strategies: [
        NbPasswordAuthStrategy.setup({
          name: 'email',
          token: {
            class: NbAuthJWTToken,
            key: 'data.token', 
          },
          baseEndpoint: 'http://api.mydomain.com/api',
          login: {
            redirect: {
              success: '/pages/project/all-project',
              failure: null
            },
            endpoint: '/login',
            method: 'post',
          },
          register: {
            endpoint: '/register',
            method: 'post',
          },
          logout: {
            endpoint: '/auth/sign-out',
            method: 'post',
          },
          requestPass: {
            endpoint: '/auth/request-pass',
            method: 'post',
          },
          resetPass: {
            endpoint: '/auth/reset-pass',
            method: 'post',
          },
        }),
      ],
      forms: {},
    }),

我成功登录但标题中没有令牌,我如何在用户登录时添加它?

4

0 回答 0