javascript - 如何在 Angular 中使用 HttpClient 访问传入消息对象?
问题描述
我正在从我的 Angular 文件向服务器发送以下请求。可以从我的打字稿文件(最好使用 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
}
},
}
我正在后端调用 API,并且我想检查在我进行调用时是否正在发送此消息。所以,我想知道它是否可以使用 HttpClient 对象访问。
解决方案
如果您只是想查看请求和响应,Chrome DevTools Network 选项卡将为您提供所有这些信息。发出请求时,必须打开 DevTools。
推荐阅读
- python-3.x - 删除python中的url/@等
- database - React:创建不同的用户配置文件
- windows - 在 windows cmd 中的一行上写两个命令时,有没有办法分隔变量名?
- python-3.x - 使用 Python 请求抓取 ajax 网站
- ruby-on-rails - 在 Rouge 语法高亮中使用 ERB 块作为文字
- variables - 在 Dax 中添加静态表
- database - 无法从数据库表中获取消息。ErrorException say:count(): 参数必须是数组或者实现了Countable的对象
- apache-spark - 在 spark 2.3.2 中,调用 Dataset.count() 时出现 java.lang.ClassCastException
- excel - 从excel中的字符串中提取日期并复制到新行
- angular - 如何在不重新渲染整个页面的情况下更新 observable 的部分值?