gpt4 book ai didi

javascript - Angular .js :12759 : OPTIONS 405 (Method Not Allowed)

转载 作者:行者123 更新时间:2023-12-03 16:32:00 26 4
gpt4 key购买 nike

我正在用 angular js 实现 http 请求但是当我传递 http 请求时,由于 json POST 表单数据,我不断收到错误代码 405 Method not allowed 我正在使用 header application/json

 var data_add_cart = {
service_type : "1",
product_details : product_array,
edit_main_id : "0",
edit_sub_id : "0",
api_key: "iZXFJIAFaLVWDx3qmpXuXRnCEsjAU6DZNwt6bEzONAHk4RoRWkyjutho7PQgZlFSYFqEZuspMzubzz0Lg8iXIIQ/t+oyheL4HxGouRJlz8o=",
log : "",
language_code: "en",
branch_id: "1",
device_type: "android",
lat : "",
device_token: "ex7n_U-pwlQ:APA91bGwFupIdjXEJqs4ZtdRwXLPPopDqwIU0gOH5n38ZPFEROk8WdAPQMsBxPLRd_3d8J3qIrUqUp8mEEvUjapCj7LVEOPO3kDt1lGT6r9L1C6VntoYuwbZnstfOSaZxeFXnibJXWKj",
customer_id: "0",
device_id: "38fd1dae4605918e",
app_unique_token : "274AD23D-6F62-4102-A1A9-EAECB5B0491E-android-"+$.now(),
};

console.log(JSON.stringify(data_add_cart));
$http.post('http://URLHERE/api/addtocart/', $httpParamSerializerJQLike(JSON.stringify(data_add_cart)), {
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Accept': 'application/Json'
}
})

我也在 .NET(API) 方面进行了更改。但没有得到适当的结果

我启用了 CORS,还在网络配置中添加了所有方法,即 GETPOSTHEADPUT , OPTION 但仍然出现同样的错误

我得到以下错误

-> angular.js:12759 OPTIONS http://URLHERE/api/add_to_cart 405 (Method Not Allowed)

-> Failed to load http://URLHERE/api/add_to_cart: Response for preflight has invalid HTTP status code 405

最佳答案

$http({ '网址':'http://URLHERE/api/addtocart/ ', '数据':data_add_cart, 'Method': 'POST', headers: 标题})

关于javascript - Angular .js :12759 : OPTIONS 405 (Method Not Allowed),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47766727/

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