[SOLVED] Error unAuthorized when query data

Hi guys,
I ve been logged on to Moralis on front end thru Metamask. the network is correct. But strangely It shows error Unauthorized when I am querying my data…

const querySomeRows = async (params) => {

    const QClass = Moralis.Object.extend(params.classStr);

    var query = new Moralis.Query(QClass);

    query.equalTo(params.sortByColumn, params.rowEqualTo);

    if (params.limit) {


        var result = await query.find(); // <==== thowing error: Unauthorized

    return result;


I ve checked with dash board, table is exist, I even created some columns. But it still not works…

did you try to add some data in that table?
did you check that you are querying the table that you expect to query? (you could use console.log to be sure)

___.queryStrategy = async () => {
	//     {classStr:   sortByColumn:  rowEqualTo: limit}
	const QClass = Moralis.Object.extend("Strategies");
	var query = new Moralis.Query(QClass);
	query.equalTo("userId", "asaasas");
	try {
		var result = await query.find();
	} catch (err) {
		console.log("Error catched: ", err);
		result = { Error: err };
	return result;

I ve simplified it, but it still not works; Sure the table name is correct.

running this in a browser console gives me no error (but I didn’t create the table)

I found it! I ve created logic to apply API key and serverUrl for each server, but because the typo, it logged into diffrent server :slight_smile:

1 Like