Error: 500 Cannot read properties of undefined (reading 'prototype')
riku-smile opened this issue · 2 comments
riku-smile commented
Summary
Hi. When I use "rss-parser" with NuxtJS, I can't read propaties.
Also, using your exapmle code will not read properties.
How can I resolve this error?
p.s.
I can get propaties in console.
But I can't get propaties in localhost browser(chrome).
Error Message
500
Cannot read properties of undefined (reading 'prototype')
at http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:6221:50
at node_modules/sax/lib/sax.js (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:7420:7)
at __require (http://localhost:3000/_nuxt/node_modules/.vite/deps/chunk-RSJERJUL.js?v=266961e3:3:50)
at Object. (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:7520:13)
at node_modules/xml2js/lib/parser.js (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:7877:8)
at __require (http://localhost:3000/_nuxt/node_modules/.vite/deps/chunk-RSJERJUL.js?v=266961e3:3:50)
at Object. (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:7901:16)
at node_modules/xml2js/lib/xml2js.js (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:7916:8)
at __require (http://localhost:3000/_nuxt/node_modules/.vite/deps/chunk-RSJERJUL.js?v=266961e3:3:50)
at node_modules/rss-parser/lib/parser.js (http://localhost:3000/_nuxt/node_modules/.vite/deps/rss-parser.js?v=266961e3:8374:18)
Code
<script setup lang="ts">
import { randomUUID } from "crypto";
import Parser from "rss-parser";
let parser = new Parser();
const qiitaFeed = await parser
.parseURL(`https://qiita.com/${myQiitaId}/feed.atom`)
.then((res) =>
res.items.map(
(d): PostContent => ({
_id: d.guid ? d.guid : randomUUID(),
title: d.title,
description: d.summary,
body: d.content,
image: undefined,
created_at: d.pubDate ? d.pubDate : today.toString(),
updated_at: d.pubDate,
_path: d.link,
})
)
);
console.log(qiitaFeed);
</script>
Env
"devDependencies": {
"nuxt": "^3.0.0"
},
"dependencies": {
"@nuxt/content": "^2.3.0",
"@nuxtjs/tailwindcss": "^6.2.0",
"rss-parser": "^3.12.0",
"sass": "^1.57.1",
"vue3-carousel": "^0.2.9"
}
DaDlugosch commented
@riku-smile Try to use Nuxt /server
directory (https://nuxt.com/docs/guide/directory-structure/server) for that. I had the same issue, and I had fixed it by moving the code to the server part (thanks to Nitro server engine). Then I called my server API through useFetch
method, and as a route or query params I set the URL which I wanted to be parsed.
riku-smile commented
I could fix this issue! Thank you @DaDlugosch for your advice. :)
I fixed it, and close this Issue.