I am trying to update customer tag on Shopify by using its private app. I tried it with postman and everything is working fine but via AJAX, it takes me to success callback instead of error but in success I get auth link instead of customer record like I get in postman.
$.ajax({
type: "POST",
url: "https://secret:[email protected]/admin/customers/1569902297146.json",
contentType: 'application/json',
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "[email protected]",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
3
Answers
I did not find any productive answer/info over the internet. Finally, After hit and trial with AJAX I am able to get success result.
The real hero is crossDomain. I don't know why Shoify do not allow its PUT and POST requests without making crossDomain: true,
I think you didn’t need to use
JSON.stringify
send data like an object
You are doing it all wrong. If you continue to expose your password on the front-end like that, you will quickly find someone will use it to turn all your Customers into porn star names with the result that you will lose your job, and your credibility. Instead, you use the App Proxy built into your private App to do non-CORS, safe, secure callbacks, without the password being involved.