let ep = "https://versatileapi.herokuapp.com/api";
//register function
let regist = function () {
let cmd = "/user/create_user";
let data = { "name": "naomi_mcrn", "description": "文鳥しゃんぬーむぬーむ" };
let succ = function (d) {
window._ajax_result = d;
alert(d);
};
$.post(ep + cmd, JSON.stringify(data), succ);
}
//bark function
let bark = function (text) {
let cmd = "/text";
let data = { "text": text };
let succ = function (d) {
window._ajax_result = d;
$.ajaxSetup({
headers: {}
});
alert(JSON.stringify(d));
};
$.ajaxSetup({
headers: { "Authorization": "HelloWorld" }
});
$.post(ep + cmd, JSON.stringify(data), succ);
}
//list function
let timeline = function (limit) {
limit = limit || 20;
let cmd = "/text/all?$orderby=_created_at desc&$limit=" + limit;
let succ = function (d) {
window._ajax_result = d;
alert(JSON.stringify(d));
};
$.get(ep + cmd, succ);
}
let users = function () {
let cmd = "/user/all";
let succ = function (d) {
window._ajax_result = d;
alert(JSON.stringify(d));
};
$.get(ep + cmd, succ);
}
//regist();
//bark("文鳥へふへふ");
//timeline(10);
//users();
//↑これ実装した後 コンソールで「_ajax_result.forEach(u => {console.log("[" + u.name + "]: " + u.description )})」を打つ
コメント