As I read from formspark documentation we can use GET methods in formspark. If I understood correctly, the GET method in JS fetch() API means that we want to retrieve data from somewhere. So I wrote this code to get my data (data that were created before from submissions in formspark) with JS fetch method:
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));
But it gives me an empty object as a response data! while I have six submissions in my account now. Could someone please help me that what is wrong in my code?
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.g https://submit-form.com/22).
Here is the snippet with the change applied
async function fetchText(formId) {
let response = await fetch(`https://submit-form.com/${formId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
}
})
let data = await response.json();
console.log(data);
return data;
}
const targetFormId = 441; // Here should be a valid actual form ID
fetchText(targetFormId).then(r => console.log(r));