解决方法ngxRestangular

时间:2018-06-04 20:11:09

标签: angular ngx-restangular

我正在尝试解决此问题in which the plus sign is being left as is in the query parameters which get interpreted as spaces on the server instead

问题是我正在使用ngxRestangular,所以我不清楚如何解决这个问题。

我尝试使用addFullRequestInterceptor如下所示,但它导致我的所有查询参数都被双重编码。

this.restangular.withConfig((restConfig) = > {
    restConfig.addFullRequestInterceptor((element, operation, path, url, headers, params) => {
        for (let param in params) {
            params[param] = encodeURIComponent(params[param]);
        }
        return {params, headers, element}
    });
})

我也尝试添加HttpInterceptor exactly as described in the Angular docs,但似乎没有开火。

如何使用此库解决此问题?

0 个答案:

没有答案