· 6 years ago · Nov 20, 2019, 04:12 PM
1// Shopify Endpoint
2var myStore = 'https://{store name}.myshopify.com/admin/api/2019-10/customers/2703768092750.json';
3// Accesing endpoint from a browser will work without problem ...
4
5// However to make it work, we are going to use the cors-anywhere free service to bypass this
6var proxy = 'https://cors-anywhere.herokuapp.com/';
7
8$.ajax({
9 beforeSend: function (xhr) {
10 xhr.setRequestHeader ("Authorization", "Basic " + btoa("api key" +":"+ "api secret"));
11 },
12 type: "PUT",
13 url: proxy + myStore,
14 data: {
15 // This is filler data. Since even the $("#editNameForm").serialize() is not working
16 "customer": {
17 "id": "{{ customer.id }}",
18 "tags": "New Customer, Repeat Customer",
19 "note": "Placed an order that had a fraud warning"
20 }
21 },
22 success: function(data){
23 console.log(data);
24 },
25 error: function(res){
26 console.log(res);
27 }
28});