Why am I getting Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information?

I have the following code enabling a user to sign up in the backend:

export function signup(username, email, password) {
    return new Promise((resolve, reject) => {
        try {
            let toInsert = {
                'title': username,
                'email': email,
                'password': password,
                'wsmoStatus': false,
                'ssmoStatus': false
            };

            wixData.insert('members', toInsert, options)
                .then(() => {
                    authentication.register(email, password)
                        .then(() => {
                            resolve('success');
                        })
                        .catch((err) => {
                            removeItemMembers(email);
                            resolve(err);
                        });
                })
                .catch((err) => {
                    resolve(err);
                });
        } catch (err) {
            resolve(err);
        }
    });
}

I have a private data collection “members” to which I try to input the info provided. The “options” contains suppressAuth and suppressHooks. I call this from the frontend this way:

import { signup } from 'backend/MemberBackend';
import wixLocation from 'wix-location';

$w.onReady(function () {
    $w('#signup').onClick(() => {
        let username = $w('#username').value;
        let email = $w('#email').value;
        let password = $w('#password').value;
        console.log(username, email, password);
        signup(username,email,password)
            .then((result) => {
                if(result === 'success'){
                    wixLocation.to('/my-profile');
                } else {
                    console.log(result);
                    console.log('Error. Could not signup');
                    //TODO: Add error message DOM
                    //TODO: See what types of errors are returned
                }
            })
            .catch((err) => {
                console.log(err);
                console.log('Oops! An error has occured. Could not signup.');
                //TODO: Add error message DOM
                //TODO: See what types of errors are returned
            });
    });
});

However, in the console on my website when I try this, it gives me the following error:
Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.
Why is this happening? Thanks in advance.

Maybe the collection permissions are the issue here.
You should check if they’re OK.
Also don’t look at the browse console (it’s an error on the backend), but use the site monitoring site tool.

As for your code.
It’s not a good practice to nest promises. You should chain them with return s.

  • you’re not returning the promises at all.

Instead of:

queryA()
    .then(r => {
        queryB()
        .then(r1 => {
            queryC()
        })
        .catch(err => err)
    })
    .catch(err => err)
})
.catch(err => err)

Do:

return queryA()
.then(r => {
    return queryB();
})
.then(r => {
    return queryC();
})
.catch(err => err)

Thank you! I will check out the site monitoring thing. Also thanks for the tip on the promises! I will come back if I have any more questions.

I still need help. I looked in the site monitoring and it gives me

[“Error loading web module backend/MemberBackend.jsw: Cannot read property ‘bind’ of undefined”]

Also I don’t think it’s a permission issue since I’m using suppressAuth.

Maybe you will find your answer here…