I am trying to call an xsjs file from another xsjs file using xshttpdest in XSA. The developer guide mentions a word on xshttpdest using destinationProvider property in sap-xsjs. I tried implementing it but I keep facing the error.
And the following is my folder structure for the xsjs app
Sorry for stuffing the image!
If you look at the File.xsjs, the first line reads the xshttpdest and this is where it runs into the error.
var dest = $.net.http.readDestination("TestXSJS.xsjs.lib.myFolder", "myFile"); var client = new $.net.http.Client(); var req = new $.web.WebRequest($.net.http.GET); client.request(req, dest); var response = client.getResponse(); var body = undefined; if (response.body) var body = response.body.asString(); $.response.contentType = "text/plain"; $.response.setBody(body);
And in start.js as per the developer guide I have mentioned the following code piece:
var xsjs = require('sap-xsjs'); var xsenv = require('sap-xsenv'); var port = process.env.PORT || 3000; console.log('here'+ port); var options = xsenv.getServices({ hana:{tag:'hana'}, uaa:{tag:'xsuaa'} }); options.destinationProvider=function getDestinationSync(packagename, objectname, dtDescriptor) { console.log('I am being executed'); }; xsjs(options).listen(port); console.log('XSJS application listening on port %d', port);
Lines 6-8 is what I have added to have the xshttpdest identified but I keep getting the error I posted in the image above.
The following is what my manifest file looks like:
--- applications: - name: web075361 port: 65100 path: ui memory: 2048M instances: 1 env: destinations: > [ {"name":"xsjs", "url":XXXXX:65101", "forwardAuthToken": true} ] services: - sp-hdi - sp-uaa - name: xsjs075361 port: 65101 memory: 1024M instances: 1 path: xsjs services: - sp-hdi - sp-uaa
There is no material/working example available yet to try this out. Any inputs on this more elaborate than what is mentioned in the developer guide for XSA would be really helpful.
Thanks.