gpt4 book ai didi

javascript - Angular js - 未添加对服务的 PUT 请求的 URL

转载 作者:太空宇宙 更新时间:2023-11-04 12:37:13 25 4
gpt4 key购买 nike

这是我的脚本:

var shipResource = $resource('http://localhost\\:8083/consignments/:cId', null, {ship: {method: 'PUT'}});

$scope.shipConsignment = function() {
if($scope.selectedConsignment != null){
var consignId = $scope.selectedConsignment.consignmentId;
console.log(consignId) //works fine
shipResource.ship({cId: "consignId"}); //not working? cId is not added to URL
}
};

和 HTML:

<button type="button" ng-click="shipConsignment()">Ship</button>

在服务端,我有一个用于 URL 的 PUT 请求的函数:localhost:8083/consignment/{consignmentId}。

但请求正在发送到 localhost:8083/consignment。这给我 405 方法不允许。任何帮助将不胜感激。

最佳答案

然后试试这个:

$resource('http://localhost\\:8083/consignments/:id', {Id: "@cId"}, {ship: {method: 'PUT'}});

关于javascript - Angular js - 未添加对服务的 PUT 请求的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37202474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com