Modify CMS collection's data with JavaScript?

Hi !

How can I modify a data of a CMS collection with JavaScript in “custom code” please ?

There isn’t a way to access the Webflow CMS API directly from client-side script, so you need a middle-tier.

If you’re comfortable with Javascript and forms, and only need to update one record at a time, Logic is a good option here. You’d pass your data into a hidden form and submit it, and Logic would take over.

There are a lot of popular 3rd party automation services as well like Make.com that can perform CMS updates.

Thank you for your answer.

Then how does the registration work?

I’m not sure what you mean by registration here.

Welcome @Sarrx :wave:

You can’t do that directly from the web browser, Webflow blocks this. If you try you’ll get something called a CORS error showing up in your web browser console.

The reason being is that they don’t want you storing your API’s private key (essentially your password) in Javascript for anyone to read.

So instead…

You have to have your web browser JS call some backend that does what you need with the CMS (so it can securely store your API key / password) and then returns that (as a JSON blob) back to your web browser’s custom code for display.

You can very easily do this with Webhook Endpoints.

That linked tutorial walks you through the basic concepts and shows you how to do it with Airtable.

This screencast:

Will show you how to submit data to Make (Integromat) where you can then update the Webflow CMS, and it returns a JSON blob that some custom code can now display.

It includes the custom code (Javascript) examples.

You’ll notice the form submit is captured in custom code, you can just skip the form submit if you want to trigger this 100% from Javascript instead.

Good luck!