feature, not a bug

This commit is contained in:
Tejas Panchal
2026-03-01 12:39:28 +05:30
commit a6184c63d4
91 changed files with 6797 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import extractCharacter from "../extractors/characters.extractor.js";
const getCharacter = async (req, res) => {
const id = req.params.id;
try {
const characterData = await extractCharacter(id);
// Ensure the data is structured correctly
if (!characterData || characterData.results.data.length === 0) {
return res.status(404).json({ error: "Character not found." });
}
return res.json(characterData); // Return the desired structure
} catch (e) {
console.error(e);
return res.status(500).json({ error: "An error occurred" });
}
};
export default getCharacter;