The Source Adapter Response API provides access to the HTTP response context (typically as a variable called resp
) and can be used in your model or controller. The response object manages the control flow of your JavaScript business logic, so it is important to always call resp.send() in your functions so that they don’t hang.
A hash of parameters available from the request.
createObject = resp.params.create_object; var postData = JSON.stringify({ 'product': createObject }); // ... resp.send('someId');
Access the response headers.
resp.header['Content-Type'] // 'application/json' resp.send(true);
Return program control.
Most controller and model methods will need to do this.
app.get('/status', {}, function(req,resp){ resp.send('ok'); });
Set an exception for the response.
resp.exception = 'Error accessing web service!'; resp.send(true);
Returns the current user of the response context.
app.get('/echo_user', {}, function(req,resp){ var user = resp.currentUser; resp.send(user); });