You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i run my next application and call api/post then this error occurs
` OverwriteModelError: Cannot overwrite `Post` model once compiled.
at Mongoose.model (/Users/mac/Practice/portfolio_projects/ai-image-generation/node_modules/mongoose/lib/index.js:582:13)
at eval (webpack-internal:///(api)/./src/database/mongodb/models/post.ts:31:62)
at (api)/./src/database/mongodb/models/post.ts (/Users/mac/Practice/portfolio_projects/ai-image-generation/.next/server/pages/api/post.js:52:1)
at __webpack_require__ (/Users/mac/Practice/portfolio_projects/ai-image-generation/.next/server/webpack-api-runtime.js:33:42)`
somehow i fixed this issue with some changes in Post.tsx
const Post = mongoose.model("Post") || mongoose.model("Post", PostSchema);
but again when i hit api/post
every time this issues occurs
error - MissingSchemaError: Schema hasn't been registered for model "Post".
Use mongoose.model(name, schema)
at Mongoose.model (/Users/mac/Practice/portfolio_projects/ai-image-generation/node_modules/mongoose/lib/index.js:549:13)
Expected Behavior
application should work this setup
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64
Binaries:
Node: 18.12.1
npm: 8.19.2
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.1.6
eslint-config-next: 13.1.6
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
https://github.com/JahanzaibTayyab/portfolio_projects/tree/main/ai-image-generation
To Reproduce
Whenever i request for data then end point throw an error.
Describe the Bug
Mongodb connection
Post.tsx
Post Data API
When i run my next application and call api/post then this error occurs
somehow i fixed this issue with some changes in Post.tsx
but again when i hit api/post
every time this issues occurs
Expected Behavior
application should work this setup
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: