Attempting to send data to API servers is resulting in a 404 error. Testing it on Postman shows that everything works fine. JSONP is being used for posting data due to cross-domain issues. The console displays the following:
GET http://myapi.com/registrations.json 404 (Not Found) angular.js:8227
undefined 0 function (name) {
if (!headersObj) headersObj = parseHeaders(headers);
if (name) {
return headersObj[lowercase(name)] || null;
}
return headersObj;
}
Object {method: "JSONP", transformRequest: Array[1], transformResponse: Array[1], url: "http://shipit-integration.herokuapp.com/registrations.json", data: Object…}
data: Object
registration: Object
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0a5ada1a9ac80a5b8a1adb0aca5eea3afad">[email protected]</a>"
password: "pass1234"
__proto__: Object
__proto__: Object
__defineGetter__: function __defineGetter__() { [native code] }
__defineSetter__: function __defineSetter__() { [native code] }
__lookupGetter__: function __lookupGetter__() { [native code] }
__lookupSetter__: function __lookupSetter__() { [native code] }
constructor: function Object() { [native code] }
hasOwnProperty: function hasOwnProperty() { [native code] }
isPrototypeOf: function isPrototypeOf() { [native code] }
propertyIsEnumerable: function propertyIsEnumerable() { [native code] }
toLocaleString: function toLocaleString() { [native code] }
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
get __proto__: function __proto__() { [native code] }
set __proto__: function __proto__() { [native code] }
headers: Object
Accept: "application/json"
Content-Type: "application/json"
__proto__: Object
method: "JSONP"
transformRequest: Array[1]
transformResponse: Array[1]
url: "http://myapi.com/registrations.json"
__proto__: Object
Below is the provided code snippet:
var data = {
"registration": {
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="20454d4149...@example.com">[email protected]</a>",
"password": "pass1234"
}
};
var headers = {
'Accept': 'application/json',
'Content-Type' : 'application/json'
};
$http({
method: 'JSONP',
url: 'http://myapi.com/registrations.json',
data: data,
headers: headers
})
.success(function (data, status, headers, config) {
console.log(data, status, headers, config);
})
.error(function (data, status, headers, config) {
console.log(data, status, headers, config);
});
What might be missing from this setup?