I’m having issues in the console with an error of too many requests 429
I have had some help in the past with backend coding. At the time it was too complex for me. The code is for Google Rich Results. I noticed the fault has been an issue for around 2 years but never did anything about this. Recently, I was looking to add some events to Google rich results and was adding the code (my skills are have improved in the past few years) and when testing, I noticed when I grey out a section of code the error disappeared.
The code is the following:
let title;
if (request.query.link) {
let link = request.query.link;
link = link.split("/");
link = link[link.length - 1];
title = link.split("-").join(" ");
}
if (!title) {
options.body = {
"error": "No Link parameter found"
};
return badRequest(options);
}
I have tried some work arounds but can’t seem to shake the fault…
This is all backend and the full code below:
import { ok, notFound, serverError, badRequest } from 'wix-http-functions';
import wixData from 'wix-data';
export async function get_categoryCourseSchema(request) {
let categorySchema = {
"@context": "https://schema.org/",
"@type": "Product",
"name": "{name}",
"image": ["{image1}", "{image2}", "{image3}"],
"description": "{description}",
};
let options = {
"headers": {
"Content-Type": "application/ld+json"
}
};
let body = {
"schemaAvailable": false,
};
let title;
if (request.query.link) {
let link = request.query.link;
link = link.split("/");
link = link[link.length - 1];
title = link.split("-").join(" ");
}
if (!title) {
options.body = {
"error": "No Link parameter found"
};
return badRequest(options);
}
try {
let results = await wixData.query("CategorySchema").eq("title", title).find();
if (results.items.length > 0) {
let item = results.items[0];
} else {
options.body = {
"error": `No result for ${title}`
};
return notFound(options);
}
} catch (error) {
options.body = {
"error": error.message
};
return serverError(options);
}
}
Any info on resolutions or Nodes that would be better suited would be great! Thank you