pjs.fiber.callNoFail()
This API is deprecated, starting in Profound.js 6. If running Profound.js 6 or higher, use Node's util.promisify() and async/await instead. See here for an example.
This API calls an asynchronous function in a top-down manner within a fiber and passes a specific this argument. If the asynchronous call fails, no error is thrown; instead, it is attached to the return value.
In JavaScript, this refers to the object that owns the JavaScript code. In those cases when the asynchronous function relies on the value for this, then pjs.fiber.callNoFail() must be used instead of pjs.fiber.runNoFail().
Parameters
The value ofÂ
this
 provided for the call.The function to call.The API assumes that the function accepts a callback as its last parameter in the following format: function(error, response). This is typical for almost all asynchronous Node.js requests. You don't have to pass the callback to the API -- it is automatically appended.
Function parameters (optional, multiple parameters can be passed).
Return Value
An object with the following properties:
success (true or false)
error (error object if success is false)
output (response output if success is true)
Exception Handling
No exceptions are thrown by this API.
Example
Call Watson Image Recognition API in a fiber
var watson = require('watson-developer-cloud');
var fs = require('fs');
var visual_recognition = watson.visual_recognition({
api_key: '{api_key}',
version: 'v3',
version_date: '2016-05-20'
});
var params = {
images_file: fs.createReadStream('./resources/car.png');
};
var response = pjs.fiber.callNoFail(visual_recognition, visual_recognition.classify, params);
if (!response.success) {
console.log(response.error);
}
else {
response = response.output;
var classifiers = response.images[0].classifiers;
}