Hello Square support.
I am trying to retrieve the list of customers in my account through the REST API, as noted in the documentation. However, when I run the code below I am not receiving any response, and the xhttp.responseText is NULL.
Could you please provide me with any guidance on how to complete this task?
Thank you in advance.
const endpoint = 'https://connect.squareup.com/v2/customers/search';
var accesstoken = 'EAAAEB4lmEG*********P0gtakZYxubfGN' //production
const xhttp = new XMLHttpRequest();
xhttp.open('POST', endpoint, true);
xhttp.setRequestHeader('Content-Type', 'application/json');
xhttp.setRequestHeader('Authorization', 'Bearer ' + accesstoken);
const requestBody = JSON.stringify({
'query': {
'filter': {}
}
});
xhttp.send(requestBody);
const response = xhttp.responseText;