I am using ember-cli with ember-data 1.8.1.I have write api in hapijs. Problem is when i am creating a new record and saving it.then it should be POST request,but it sending method 'OPTIONS', and saying 404 not found. I find error in console is :-
[Report Only] Refused to connect to 'http://localhost:3000/users' because it violates the following Content Security Policy directive: "connect-src 'self' ws://localhost:35729 ws://0.0.0.0:35729"
OPTIONS http://localhost:3000/users
XMLHttpRequest cannot load http://localhost:3000/users. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 404.
SO Here is the code which i write for saving record
var onSuccess = function(post) {
console.log(post);
};
var onFail = function(post) {
console.log("fail");
console.log(post);
};
var user = store.createRecord('user', {
email : "Email",
phone : "phone",
password : 'password',
"isd_code_id" : 1,
slug: "puneet"
});
user.save().then(onSuccess, onFail);
It always goes in fail, I already add cors in hapijs, GET request is working fine.Only problem is saving record. Please Help what should i do for make it work
Aucun commentaire:
Enregistrer un commentaire