pierreavn / websheetjs

Lightweight JS library to render website sections with data from Google Spreadsheets
https://websheet.js.org
MIT License
32 stars 7 forks source link

Uncaught TypeError: row.Category is undefined #2

Open hideosnes opened 1 month ago

hideosnes commented 1 month ago

Strangely enough, I get the error message with my own code and with the c&p code from your example. I'm running it in VS-Code with the Live Server extension. The data console-log fires correctly, but I get "Uncaught TypeError: row.Category is undefined" in Firefox. Any ideas what might be the cause? (Edit: In Chromium there's no error message at all and it doesn't render any contents of the G-Sheet.)

`

<script src="https://cdn.jsdelivr.net/gh/pierreavn/websheetjs/dist/websheet.min.js" type="text/javascript"></script>

<script>

    websheet('stuff', {
    url: 'some url',
    sheet: 'Stuff',
    // caching: true,
    onLoaded: data => {
        if (data) {
            console.log('data =', data);
        } else {
            console.error('Error loading data from URL');
            // add error handling
        }
    },
    aliases: {
            // Aliases for each category
            'foo?': row => row['Category'].value === 'oof',   // error message indicates this line
            'bar?': row => row['Category'].value === 'rab',
            'foobar?': row => row['Category'].value === 'raboof',
        },
    })
</script> <!-- </> Websheets -->`
pierreavn commented 1 month ago

Do you have a "Category" column in your Google Sheet? To debug easier, you can inspect data displayed in console with console.log('data =', data)

hideosnes commented 2 days ago

Yeah, I basically cloned the given example. However, in the end, switching from Firefox to Chrome solved the issue. After playing around with it, I also got it to run in FF but had to do some async voodoo 😅. Will post the solution ASAP/ as soon as I've got a minute to spare.