this is my node.js code :
var http = require('http');
var port = process.env.port || 1337;
var MovieDB = require('moviedb')('API KEY');
MovieDB.searchMovie({ query: 'Alien' }, function (err, res) {
console.log(res);
});
here in res, i got result, my problem is, i want to store this res in knockout observablearray and display to html page, how could i do that?
i am not able to find any links where they explained to write knockout viewmodel with node.js code.
Declare an observableArray, something similar to this -
self.movies = ko.observableArray()
and if you get collection of objects from server, assign it using following syntax -
var http = require('http');
var port = process.env.port || 1337;
var MovieDB = require('moviedb')('API KEY');
MovieDB.searchMovie({ query: 'Alien' }, function (err, res) {
console.log(res);
self.movies(res); //setter;
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.