1

次のスニペットで基本認証を使用して、ローカルで実行されているサイトに簡単な投稿要求を行うことはできますか?

app.controller('post', function($scope, $http) {


$http.post("http://localhost:8888/angular//wp-json/posts", {'title':'Posting from Angular'})
.success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available

document.getElementById("response").innerHTML = "It worked!";
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.

document.getElementById("response").innerHTML= "It did not work!";
alert(status)
});

}); 
4

1 に答える 1