Hi everyone, this is my first time posting here.
I'm having trouble sending data via the POST method.
When I checked the console, I saw the following error message: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at . (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)."
I've done some research on CORS, but the issue persists.
Below is the code I'm working with:
function track() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.aftership.com/v4/trackings/', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('aftership-api-key', 'key');
xhr.onload = function() {
if(xhr.status === 200) {
console.log('Does it work? : ' + xhr.responseText);
}
else {
console.log('IT DOESN'T WORK!' + xhr.status);
}
}
xhr.send("tracking_number=number");
//xhr.send();
}
At times, I've managed to create a tracking number using the GET method, but it's not a sustainable solution. However, I can use the DELETE method with a CORS plugin in Google Chrome after creating the tracking number. Without the plugin, the DELETE method doesn't work.
I'm interested in developing my own application on phonegap using the Aftership API.
I would greatly appreciate any help or advice! :D