gpt4 book ai didi

angularjs - 在 $resource 上发送请求正文

转载 作者:行者123 更新时间:2023-12-03 07:38:37 25 4
gpt4 key购买 nike

我看一下Angular API对于 $resource,我没有找到将 Request Body 发送到 RESTful 服务的方法。

我知道使用 $http 方法可以做到这一点,例如 here ,那么,是否也可以使用 $resource 来完成?

显然这是$resource的选项。

action – {string} – The name of action. This name becomes the name of the method on your resource object.

method – {string} – HTTP request method. Valid methods are: GET, POST, PUT, DELETE, and JSONP

params – {object=} – Optional set of pre-bound parameters for this action.

isArray – {boolean=} – If true then the returned object for this action is an array, see returns section.

目前我没有找到任何方法来发送包含 JSON 对象的请求负载。

最佳答案

基于@gargc的答案,您可以将参数和主体传递给资源的方法:

myResource.save({ param: myParam }, myObject);

关于angularjs - 在 $resource 上发送请求正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16203646/

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