简体   繁体   English

如何在 Angular 中使用 HttpClient 访问传入消息对象?

[英]How can I access the Incoming Message object using HttpClient in Angular?

I am sending the following request to the server from my Angular file.我正在从我的 Angular 文件向服务器发送以下请求。 Can this be accessed from my typescript file (preferably using a HttpClient object) ?可以从我的打字稿文件(最好使用 HttpClient 对象)访问它吗?

IncomingMessage {

  ...

  headers: {

    host: 'localhost:8080',

    connection: 'keep-alive',

    accept: 'application/json, text/plain, */*',

    'content-type': 'application/json',

    'sec-fetch-site': 'same-origin',

    'sec-fetch-mode': 'cors',

    'accept-encoding': 'gzip, deflate, br',

    'accept-language': 'en-US,en;q=0.9',

    cookie: '_iAToken=<cookie>'

  },

  ...

  url: '/teradata/databases/view/djfg',

  method: 'GET',

  baseUrl: '/api',

  originalUrl: '/api/teradata/databases/view/djfg',

  params: { '0': 'teradata/databases/view/djfg' },

  secret: '<secret>',

  cookies: {},

  signedCookies: [Object: null prototype] {

    _iAToken: '<token>'

  },

  _parsedOriginalUrl: Url {

    protocol: null,

    slashes: null,

    auth: null,

    host: null,

    port: null,

    hostname: null,

    hash: null,

    search: null,

    query: null,

    pathname: '/api/teradata/databases/view/djfg',

    path: '/api/teradata/databases/view/djfg',

    href: '/api/teradata/databases/view/djfg',

    _raw: '/api/teradata/databases/view/djfg'

  },

  session: Session {

    cookie: {

      path: '/',

      _expires: 2021-08-29T22:01:49.960Z,

      originalMaxAge: 544320000,

      httpOnly: true,

      secure: true

    },

    accessToken: '<access_token>',

    tokenset: {

      access_token: '<access_token>',

      token_type: 'Bearer',

      expires_at: 1629737347

    }

  },

}

I am making a call to an API in the backend and I wanted to check if this message is being sent when I make the call.我正在调用后端的 API,我想检查在我拨打电话时是否正在发送此消息。 So, I wanted to know if it can accessed using HttpClient object.所以,我想知道它是否可以使用 HttpClient 对象访问。

If you are just trying to see the request and response the Chrome DevTools Network tab will have all that information for you.如果您只是想查看请求和响应,Chrome DevTools Network 选项卡将为您提供所有这些信息。 The DevTools must be open when you make the request.提出请求时,开发者工具必须处于打开状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM