Error on import wixSecretsManager from 'wix-secrets-manager';

Question:
I’m trying to use Google Drive API to upload a “file upload field” data from a wix from to a google drive.

import wixData from 'wix-data';
import wixFetch from 'wix-fetch';
import wixSecretsManager from 'wix-secrets-manager'; 

$w("#wixForms1").onWixFormSubmit(() => {
    const uploadedFile = $w("#fileUpload").value[0]; 
    uploadFileToGoogleDrive(uploadedFile);
});

async function uploadFileToGoogleDrive(file) {
    // ... (Secrets fetching remains the same)

    // Get file URL from Form submission
    const fileUrl = file.url; 

    // Get file data
    const fileData = await wixFetch(fileUrl).then(response => response.arrayBuffer()); 

    // Send webhook to Integromat (replace with your actual Integromat webhook URL)
    const integromatWebhookUrl = 'https://hohttps//hook.eu1.make.com/bf8rm1x0h6kke25v1u1yznsndlkz1g5nok.integromat.com/xxxx'; 
    const response = await wixFetch(integromatWebhookUrl, {
        method: 'POST',
        body: JSON.stringify({
            fileData: fileData 
        })
    });

    // ... 
} 

This is a code I’m currently trying to use, but I get these errors:

  1. import wixSecretsManager from ‘wix-secrets-manager’; - wixSecretsManager’ is declared but its value is never read.

Cannot find module ‘wix-secrets-manager’ or its corresponding type declarations.

  1. const fileData = await wixFetch(fileUrl).then(response => response.arrayBuffer()); - This expression is not callable. Type ‘typeof import(“wix-fetch”)’ has no call signatures.

are there any ways to fix it?

Hey! I saw you asked this question in Discord as well. I answered there, but for visibility for others passing through - your secrets manager code is not quite correct. It also belongs in the backend. It’s important not to access secrets in your frontend/page code as this creates a security risk.

Take a look at the docs and if you are more of a video person, I’ve linked a video on setting up and using the secrets manager

I would start with this error first and then you can move on to working with the file upload code