SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
Список вопросов ПечатьМетки: axios json javascript json-rpc
| RemiZOffAlex Создано: 2018-08-11 21:10:39.077757 Обновлено: 2018-08-11 21:10:39.077757 |
|---|
axios.post({
url: '/tag',
data: { tag: 'axios' },
headers: { 'content-type': "application/x-www-form-urlencoded; charset=UTF-8" }
}).then(
function(response) {
if (response.status==200) {
// code
}
}
).catch(
function (error) {
if (error.response.status==404) {
// code
};
}
);
REST APIPOST
// Новое событие
newEvent: function() {
var vm = this;
axios.post(
'/event',
{
title: vm.newEventTitle
}
).then(
function(response) {
if (response.status==201) {
vm.events.push(response.data);
}
}
);
},
JSON-RPC
// Новое событие
newEvent: function() {
var vm = this;
axios.post(
'/api',
{
"jsonrpc": "2.0",
"method": 'event.add',
"params": {
title: vm.newEventTitle
},
"id": 1
}
).then(
function(response) {
if ('result' in response.data) {
vm.events.push(response.data['result']);
}
}
);
},
|