Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #2

Open
maximus2425 opened this issue Oct 2, 2024 · 0 comments
Open

issue #2

maximus2425 opened this issue Oct 2, 2024 · 0 comments

Comments

@maximus2425
Copy link

hey, i have an issue with the code when i used your code which says

⨯ pages\api\generate.ts (27:32) @ post
⨯ TypeError: Cannot read properties of undefined (reading '0')

at post (webpack-internal:///(api)/./pages/api/generate.ts:25:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handler (webpack-internal:///(api)/./pages/api/generate.ts:37:13)
at async K (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\compiled\next-server\pages-api.runtime.dev.js:21:2871)
at async U.render (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\compiled\next-server\pages-api.runtime.dev.js:21:3955)
at async DevServer.runApi (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\next-server.js:598:9)
at async NextNodeServer.handleCatchallRenderRequest (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\next-server.js:269:37)
at async DevServer.handleRequestImpl (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\base-server.js:810:17)
at async C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\dev\next-dev-server.js:339:20
at async Span.traceAsyncFn (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\trace\trace.js:154:20)
at async DevServer.handleRequest (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\dev\next-dev-server.js:336:24)
at async invokeRender (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\lib\router-server.js:173:21)
at async handleRequest (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\lib\router-server.js:350:24)
at async requestHandlerImpl (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\lib\router-server.js:374:13)
at async Server.requestListener (C:\Users\HP\Desktop\cooking\chef-ai\node_modules\next\dist\server\lib\start-server.js:141:13) {

page: '/api/generate'
}

25 | const data = await response.json();
26 |

27 | const recipes = data.choices[0].message.content
| ^
28 | .split("\n")
29 | .filter((line: string | any[]) => line.length > 0);

could you please help me to solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant