typescriptdotnetnuke2sxc

How to return a text value from 2sxc events app post?


We're using the events course and registration app. Whenever we do a registration, the formscontroller API is called so it seems. However, we modified it, so it calls another API. This API returns a message which in turn we want the formcontroller to return to the form. So that is where the difficult part is so it seems. So at the end of the formcontroller we are saying something like

return textvalue;

And even with developer tools under network, we can see the value being returned in the response. However we can't seem to get the value on the form. So in the index.ts we do something like:

sendForm(formValues, submitButton, endpoint)
  .then((result: any) => {
    console.log(result);

However we don't see the textvalue anywhere .... Does anyone have an idea how to do something like this?


Solution

  • The default FormController returns void

      [HttpPost]
      public void ProcessForm([FromBody]Dictionary<string,object> contactFormRequest)
    

    If your code was changed to return something in this function you would get an error, so I assume you either changed it, or you're returning something on another function (not ProcessForm).

    A simple change would help you figure it out step by step - do something like this:

      [HttpPost]
      public string ProcessForm([FromBody]Dictionary<string,object> contactFormRequest)
      {
        return "test";
      }
    

    this should return the string test and then you can work your way up from there.