我可以使用JS fetch()API从Formspark获取表单数据吗?
当我从 formspark文档我们可以使用 get get
get
方法在JS fetch()API中表示我们要从某个地方检索数据。因此,我编写了此代码以获取使用JS Fetch方法的数据(从Formspark中提交的数据之前创建的数据:
async function fetchText() {
let response = await fetch('https://submit-form.com/my-id', {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
}
})
let data = await response.json();
console.log(data);
return data;
}
fetchText().then(r => console.log(r));
但这给了我一个空的对象作为响应数据!虽然我的帐户中有六个提交的内容。有人可以帮我,我的代码中的错误吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
后端返回以下消息
此表单不再存在
。如果我对文档中的URL样本进行相同的操作。它给我以下错误
因此,您需要做什么是用URL中的表单ID替换
my-id
(例如https:// submit-form.com/22
)。这是应用更改的片段
The backend returns the following message
This form does not exist anymore
.If I do the same with the URL sample from the documentation. It gives me the following error
So what do you need to do is to replace the
my-id
with your form ID in the URL (e.ghttps://submit-form.com/22
).Here is the snippet with the change applied