Skip to content

Instantly share code, notes, and snippets.

@anttti
Created December 5, 2015 08:43
Show Gist options
  • Save anttti/56cf2ce025b0321e66d4 to your computer and use it in GitHub Desktop.
Save anttti/56cf2ce025b0321e66d4 to your computer and use it in GitHub Desktop.
$(function() {
$("#axios").on("click", function() {
axios.post("http://wordpress.dev/wp-json/wp/v2/movie", {
title: $("#title").val(),
status: "publish"
}, {
headers: {
"Authorization": "Basic YWRtaW46YWRtaW4="
}
}).then(function(res) {
console.log(res);
}).catch(function(err) {
console.log(err);
});
});
$("#jquery").on("click", function() {
$.ajax("http://wordpress.dev/wp-json/wp/v2/movie", {
method: "post",
headers: {
"Authorization": "Basic YWRtaW46YWRtaW4="
},
data: {
title: $("#title").val(),
status: "publish"
}
}).done(function(res) {
console.log(res);
}).fail(function(err) {
console.log(err);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment