inserting to database

This my code, but it doesn’t work. Every time the text message says no and it doesn’t insert anything to the database.

import wixData from 'wix-data';

     

export function sumbit_click(event) {
    
  
 let toInsert = {
        "title": "hello"
    
       
 };

        wixData.insert("Shoes", toInsert)
        .then(() => {
             $w("#textmessage").text = "YES.";
             
        

            

        }).catch((err) => {

            $w("#textmessage").text = "No";

        })
}

Check the permission of your collection if you have set it to “Anyone” who can create content for that specific collection.

You can also try and add this piece of code to bypass the permission of your collection.

let options = {
“suppressAuth” : true ,
“suppressHooks” : true
};

wixData . insert ( “Shoes” , toInsert, options ). then (() => { $w ( “#textmessage” ). text = “YES.” ;