首页 > 解决方案 > 在 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}/

标签: angular

解决方案


是get还是post?

无论如何你可以这样做:

return this.http.post(this.campaignUrl + uuid);

推荐阅读