在角度8中将ID动态发送到proxy.config.json

问题描述

在以下情况下,我无法发送“ id”。
例如:url = somedomain/{id}/emp 为此,我将proxy.config.json文件中的网址设置为

"/employee": {
  "target":"somedomain","secure":false,"pathReWrite: {
    "/employee":""
  }
}

现在在我称为Angular Service文件

this.http.post(`http://localhost:4200/employee/{id}/emp`);

在这种情况下,总URL仅替换为/ employee。但是我想通过proxy.config.js文件动态发送“ id”。您能帮我解决这个问题吗?预先感谢。

解决方法

我猜你有错字。

W中的w替换大写字母pathReWrite

   should be w
       \/
"pathReWrite: {
  "/employee":""
}