How do I get the value of the text from the example below?
Q.js has an example on using Deferred:
var deferred = Q.defer();
FS.readFile(\"foo.txt\", \"ut
You can get the value via the .then() method of a Promise:
function read() {
// your snippet here...
}
read().then(function (text) {
console.log(text);
});
Also, error handlers can be passed either as a 2nd argument to .then()
or with the .fail()
method:
read().fail(function (err) {
console.log(err);
});