Skip to content

Unable to save document (form submissions) with REST API #914

Answered by JarrodMFlesch
thefrana asked this question in Q&A
Discussion options

You must be logged in to vote

That should work...

Here is a snippet pulled from a site my team built.

const dataToSend = Object.entries(data).map(([name, value]) => ({
  field: name,
  value
}));

const req = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/form-submissions`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    form: formID,
    submissionData: dataToSend
  })
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thefrana
Comment options

Answer selected by thefrana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants