Есть такой кусок кода на jquery с постом на сервер:
//Build the command string that will be passed to the spark core's
//setRgb function. The command will be in the format of "r,g,b"
var command = localRed + ',' + localGrn + ',' + localBlu;
//Create the url for the spark core's setRgb function with the
//required coreId value.
var url = "https://api.spark.io/v1/devices/" + coreId + "/setRgb";
//Show the ajax_loader div to indicate that the post has begun
//the div overlays the slider controls and prevents the sliders
//from being changed while the update is in progress. This
$('#ajax_loader').show();
//Create a jQuery.ajax request to post the new RGB values to the setRgb function
$.ajax({
type: "POST",
url: url,
data: {
access_token: accessToken,
args: command
},
}).then(function () {
//Then set the posting flag to false so another post can run
posting = false;
//hide the ajax_loader div
$('#ajax_loader').hide();
});
};
не могу переписать на https://github.com/pagekit/vue-resource
вот что получается у меня, коннект проходит, access_token вставил в запрос, а вот доп аргументы localRed + ',' + localGrn + ',' + localBlu не могу передать:
this.$http.post('https://api.spark.io/v1/devices/3b0041000747343232363230/setRgb?access_token=ba2b57075f7261d9751ef46c50fe3440d5ef1c8d').then(function(response) {
console.log("Sucess post")
}, function(error) {
console.log("Error post!")
})
var command = localRed + ',' + localGrn + ',' + localBlu;
var url = 'https://api.spark.io/v1/devices/3b0041000747343232363230/setRgb?access_token=ba2b57075f7261d9751ef46c50fe3440d5ef1c8d';
this.$http.post(url, { args: command }).then(function(response) {
console.log("Sucess post")
}, function(error) {
console.log("Error post!")
})
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Всем приветСейчас осваиваю Javascript через книгу "Выразительный javascript"