angular - 打字稿http获取请求
问题描述
我正在尝试为使用 angular 2 的学校俱乐部编辑代码,我需要在 component.ts 文件中发出 http get 请求。我不需要从中获取任何信息,因为它只是向正在侦听请求的服务器发送请求。从谷歌搜索尝试了多种方法,但没有得到任何地方。
解决方案
HTTP 通过fetch()
API获取
节点.js
节点本身没有fetch
。安装node-fetch
和使用它:
const fetch = require('node-fetch');
// in an async function...
await fetch('URL').then(res => res.text());
浏览器
这很简单:
// in an async function...
await fetch('URL').then(res => res.text());
推荐阅读
- xml - 以表格形式列出ofbiz实体
- django - Django 自定义异常返回 503 并跳过发送管理员电子邮件
- c - C11 原子与序列点的关系
- sap-cloud-sdk - 目标服务 API 规范的 OpenAPI 生成器问题
- java - 传递 JVM 属性在 Dockerfile CMD 命令中包含空格
- databricks - 无法使用 GCP 在数据块中配置集群
- graphql - GraphQL Java 自定义标量的强制输入和输出类型应该是什么?
- php - 仅由 wordpress 管理员查看页面
- html - 在 HTML 中水平对齐同一行上的文本
- python - 不使用 count() 计算词频