angular - 在 Angular 6 服务中为 api url 设置参数
问题描述
我有一个需要传递一些数据的获取请求,我该如何在我的服务中做到这一点:
private campaignUrl = environment.apiUrl + '/campaign/';
constructor(private http: HttpRequestService) { }
getCampaign(uuid) {
return this.http.post(this.campaignUrl);
}
我需要在campaignUrl之后传递id,这是我在swagger中的api url:
/api/campaign/{uuid}/
解决方案
是get还是post?
无论如何你可以这样做:
return this.http.post(this.campaignUrl + uuid);
推荐阅读
- docker - Docker nginx reverseProxy 连接被拒绝
- algorithm - 给定两个整数 N 和 M。如何检查 N 是否可以表示为 M 的不同整数幂的总和?
- node.js - Google Directory API:无法使用服务帐户访问用户/组端点 (403)
- class-validator - 如何允许空,但禁止未定义?
- jmeter - 使用 jmeter 中的 jsr223 后处理器将提取的值存储在 csv 文件中
- bash - 在节点上运行 bash 脚本 srun 用于 mpi 作业
- javascript - 用于计算变量重要性的优势分析的 JavaScript 包
- twilio - Twilio Flex 通过 websocket 流式传输音频
- python - libselinux-python 绑定和 ansible
- sqlalchemy - Alembic:如何降级整个分支?