简体   繁体   中英

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. Can this be accessed from my typescript file (preferably using a HttpClient object) ?

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. So, I wanted to know if it can accessed using HttpClient object.

If you are just trying to see the request and response the Chrome DevTools Network tab will have all that information for you. The DevTools must be open when you make the request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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