Extension/GJS/API: I don't get channels of a snap

Hi all,

I just made Snap Menu GNOME extension. https://extensions.gnome.org/extension/9040/snap-menu/

It uses snapd2 library and works quite well. BUT I did not success to get channels. I get a void array with snap.get_channels() or an error with snap.channels.

I need help here as I do not understand how it works. I tried to get channels sync rather than async but the issue is the same.

I tried to make a dedicated function but same issue again:

_getSnapChannels(snap) {
            this._snapdClient?.find_async(
                Snapd.FindFlags.SCOPE_WIDE,
                snap?.name,
                null,
                (client, result) => {
                    const storeSnap = client.find_finish(result);
                    log(storeSnap);
                    return storeSnap[0][0]?.channels;
                }
            );

Thanks!

Related: https://discourse.ubuntu.com/t/snap-gnome-extension/73774

https://api.snapcraft.io/v2/snaps/find?architecture=amd64&confinement=strict%2Cclassic&fields=base%2Cconfinement%2Clinks%2Ccontact%2Cdescription%2Cdownload%2Clicense%2Cprices%2Cprivate%2Cpublisher%2Crevision%2Csummary%2Ctitle%2Ctype%2Cversion%2Cwebsite%2Cstore-url%2Cmedia%2Ccommon-ids%2Ccategories%2Cchannel&q=gimp

returns:

{"error-list":[{"code":"missing-header","message":"Snap-Device-Series header is required."}]}

and I’m stuck here.

Why are you making the request to api.snapcraft.io?

That’s the find_sync function.