英文:
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<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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论