我正在尝试使用其私有(private)应用程序更新 Shopify 上的客户标签。我用 postman 尝试过,一切正常,但通过 AJAX,它带我成功回调而不是错误,但成功后我得到了身份验证链接,而不是像我在 postman 中获得的客户记录。
$.ajax({
type: "POST",
url: "https://secret:password@store-name.myshopify.com/admin/customers/1569902297146.json",
contentType: 'application/json',
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "example@gmail.com",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
我认为你不需要使用JSON.stringify
像对象一样发送数据
$.ajax({
type: "POST",
url: "https://secret:password@store-name.myshopify.com/admin/customers/1569902297146.json",
contentType: 'application/json',
data: {
customer: {
id: "1569902297146",
email: "example@gmail.com",
tags: "loyalty-member"
}
},
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
Tôi là một lập trình viên xuất sắc, rất giỏi!