How to call customer API?

aruljothi
New Member
2 0 0

I have page there I can add metafields in Customer Object.

I'm using two APIs for that.

1.

GET -/admin/api/2020-10/customers/{customer.id} - to get the customer

which is working in admin login. But not working in admin login. But not working in user login.

 
2. PUT - /admin/api/2020-10/customers/{customer.id} - to update customer. 

 

 

fetch('/admin/api/2020-10/customers/' + customerId + '.json', {
        method: "PUT",
        headers: {
            "Content-Type": "application/json",
            "Accept": "application/json"
        },
      body: JSON.stringify({
        customer: customer
      })

 

 

 When I call in admin login (development mode) - it shows an alert box with user-name and passwords fields.

 

My questions are

1. How to get customer details in liquid file script section in customer login?

2. How to update the customer object through api from javascript?

0 Likes