如何从2sxc事件应用程序的帖子中返回文本值?

huangapple go评论57阅读模式
英文:

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

问题

我们正在使用事件课程和注册应用程序。每当我们进行注册时,似乎会调用formscontroller API。但是,我们对它进行了修改,使其调用另一个API。该API返回一条消息,然后我们希望formcontroller将其返回到表单中。这似乎是困难的部分。因此,在formcontroller的最后,我们会做出类似以下的操作:

return textvalue;

即使在开发者工具的网络选项下,我们也可以看到响应中返回的值。但是我们似乎无法在表单上获取该值。因此,在index.ts中,我们会执行类似以下的操作:

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

但是我们在任何地方都看不到textvalue.... 有人知道如何实现这样的操作吗?

英文:

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?

答案1

得分: 1

默认的FormController返回void

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

如果你的代码更改以在这个函数中返回值,你会收到一个错误,所以我假设你要么已经更改了它,要么在另一个函数中返回了值(不是ProcessForm)。

一个简单的更改可以帮助你逐步找出问题 - 像这样做一些事情:

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

这应该返回字符串test,然后你可以从那里逐步解决问题。

英文:

The default FormController returns void

  [HttpPost]
  public void ProcessForm([FromBody]Dictionary&lt;string,object&gt; 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&lt;string,object&gt; contactFormRequest)
  {
    return &quot;test&quot;;
  }

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

huangapple
  • 本文由 发表于 2023年7月17日 22:28:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76705481.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定