Xbasic

node_request_result Function

Syntax

Result as P = node_request_result (nodeService as c, pData as p [, flagRestartNode as L [, flagShowCommandWindow as L [, flagAllowDebug as L [, opsIn as P]]]])

Arguments

nodeServiceCharacter

Name of the node service to run.

pDataPointer

Pointer to parameters to pass to the node service.

flagRestartNodeLogical

.t. or .f. value. Default .f.

Flag indicating whether or not the node server should be restarted when node_request is called. .t. restarts the node server. Restarting the node server can be useful for debugging purposes. flagRestartNode should be set to .f. in a production environment.

flagShowCommandWindowLogical

.t. or .f. value. Default .f.

Show the command window for the node service handler (allows developer to see feedback using console.log() in the handler).

flagAllowDebugLogical

.t. or .f. value. Default .f.

Enable node debugger (requires that the node debugger be launched).

opsInPointer

Default = null_value(). A dot variable used to define optional Helper::NodeAttachments. Can have the following properties:

attachmentsInHelper::NodeAttachments

A Helper::NodeAttachments object to pass into the Node Service.

attachmentsOutHelper::NodeAttachments

A Helper::NodeAttachments object that is returned from the Node Service.

Returns

ResultPointer

Returns a dot variable containing the parsed JSON object returned by the Node Service. Includes the following properties:

resultAny Type

The parsed JSON results returned by the Node Service.

errorCharacter

An error message, if an error occurred. Otherwise blank.

attachmentsHelper::NodeAttachments

A Helper::NodeAttachments object that contains binary data returned from the node service.

Description

Calls a node service from Xbasic and returns the parsed JSON.

Discussion

A wrapper around the node_request() function, except that instead of returning a JSON string, the JSON is already parsed and the function returns a .result and .error property. If there was no error, the .error property is blank.

 Example

dim pIn as p
pIn.x = 4
pIn.y = 3

dim pOut as p
pOut = node_request_result("multiply",pIn)

?pOut.error
= ""  'empty string indicates no errors.

?pOut.result
= 12

 Automatic Node Restart

If you edit a Node Service, Alpha Anywhere will automatically set flagRestartNode to .T. in Live and Working Preview. If Node is not restart, any changes made to a Node Service will not be detected.

See Also