Home > database >  How to send form as json in 11ty
How to send form as json in 11ty

Time:09-22

I'm trying to send data from 11ty to my directus headless CMS. The problem here is Directus only accepts json data.

No problem to send the data with regular website, but as 11ty is a static site generator, I can't find the way to send the data as json instead of form, because I can only use javascript for receiving data.

Thanks!

CodePudding user response:

On your form, why not use JavaScript to handle the form submission and then use fetch() to hit the CMS? Basically, this is something you handle in client-side JS, via your generated site.

CodePudding user response:

As I recall, Directus provides a collection endpoint, i.e. /items/contacts where you can directly POST your form submission.

  • Related