JavaScript action returning nothing.

0
I have a JS action called getHost, its not returning anything eventhough in the code Im returning an object. Any idea why?   // This file was generated by Mendix Studio Pro. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. import "mx-global"; import { Big } from "big.js"; // BEGIN EXTRA CODE async function createMxObj(entity) { return new Promise(function(resolve,reject) { mx.data.create({ entity: entity, callback: function(obj) { resolve(obj); }, error: function(e) { reject("Could not create object:", e); } } ); }); } // END EXTRA CODE /** * @returns {Promise.<MxObject>} */ export async function getHost() { // BEGIN USER CODE const mainUrl = window.location.href; const obj = await createMxObj("Entity.hostUrl"); obj.set('Url', mainUrl); return obj; // END USER CODE }  
asked
1 answers
0

Hello Diego,

 

You need to set the return value:

image.png

In your case this will be a bit more complex because you want to give back a object, probably you first need to create this object in your domain model in order to enable it as a valid return type. 

 

Hope this helps

 

Good luck!

answered