Quantcast
Channel: DreamFactory Forum - Latest topics
Viewing all articles
Browse latest Browse all 1523

Custom service scripting

$
0
0

@sreenivas wrote:

Hi,

I have tried the Example given in http://wiki.dreamfactory.com/DreamFactory/Tutorials/V8_custom_scripting_service

and I invoked this request through postman Chrome Extension. please find the details below.

Custom Code:

var lodash = require("lodash.min.js");

if (event.request.method !== "GET") {
throw("Only HTTP GET is allowed on this endpoint.");
}

var params = event.request.parameters;

// check for required params
var required = ["n1","n2"];
lodash._.each( required, function( element ) {
if (!params.hasOwnProperty(element) || !params[element]) {
throw( "Missing '" + element + "' in params\n" );
}
});

var result = Number(params.n1) + Number(params.n2);
return result;

Requested URL:

http://127.0.0.1:10678/api/v2/add?api_key=91a0c7f374c711b06e1fbb7943b4a4d752c5fb2ec55372fb07ce26ade12be2c6&n1=9&n2=9

I get the following response.
"error": {
"context": null,
"message": "The module "lodash" could not be found in any known locations.",
"code": 500,

I checked the Dream Factory logs i found the following.

[2015-11-26 19:13:09] local.DEBUG: Service event: add.get.pre_process

[2015-11-26 19:13:09] local.DEBUG: * no "require()" support in V8 library v3.17.15

Please help me about how to resolve this

Regards,
K R Sreenivas Harshith.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 1523

Trending Articles