Rate Limit with useMoralisQuery multiple calls Next.js

Hi,

I have a hook call like

const fetchListedItems = JSON.parse(
JSON.stringify(useMoralisQuery(‘items’).data, [
‘’,
])
)

in my Next.js app, which triggers my rate limit, as it fires very often. Any chance to only excecute it once at page load?

how is that a query triggers a rate limit?

No idea, maybe the page rerenders?

what is the error that you see?

Is there a way to excecute the query like this:
const {Moralis} = useMoralis()
const Monster = Moralis.Object.extend(‘tableName’)
const query = new Moralis.Query(Monster)
JSON.parse(
JSON.stringify(await query(‘tableName’).data, [
‘columnName’,
]),
),

Could someone rewrite this code so it would work, and return an array with the table rows, containing the column data?

The error:

Unhandled Runtime Error

Error: This Moralis Server is rate-limited because of the plan restrictions. See the details about the current rate and throttle limits: {“x-rate-limit-limit”:“25”,“x-rate-limit-remaining-ttl”:“1”,“x-rate-limit-used”:“30”,“x-rate-limit-remaining-ip-ttl”:“1”,“x-rate-limit-ip-used”:“30”}

I also see, that the hook gets excecuted like 30 times - just added a console.log…

Hi,

should anyone stumble across the same Problem:

Moralis.start({serverUrl,appId})
const query = new Moralis.Query('tableName')
const itemsInTableRows = JSON.parse(JSON.stringify(await query.find()))

Solves the Problem.

strange, that error that you pasted above seems to be related to the API and not to a query.

JSON.parse(JSON.stringify Having to do that is very unusual. It doesn’t just work with await query.find()?

Hi,

sadly query.find() does not work without the two JSON conversions.