gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Description: Create api to save products in to which list, accept userId and producnt…
- User
Description: Create api to save products in to which list, accept userId and producnt id, user given wishlist shcema to save data, export functions name
codeGenerate source code based on the description above and respond in the following JSON format ONLY: ```json { "name": "prompt_name", "schema": { "type": "string", "code": "Generated code here" } } ``` IMPORTANT: - Ensure the JSON response is error-free. - Include no additional text or explanations. Respond with the JSON object only. - Assistantjson
{ "name": "saveProductToWishlist", "schema": { "type": "string", "code": "const express = require('express');\nconst app = express();\n\napp.use(express.json());\n\n// Mock database\nconst wishlists = {};\n\napp.post('/wishlist', (req, res) => {\n const { userId, productId } = req.body;\n\n if (!userId || !productId) {\n return res.status(400).json({ message: 'userId and productId are required.' });\n }\n\n if (!wishlists[userId]) {\n wishlists[userId] = [];\n }\n\n if (!wishlists[userId].includes(productId)) {\n wishlists[userId].push(productId);\n }\n\n return res.status(200).json({ message: 'Product added to wishlist.' });\n});\n\nconst PORT = process.env.PORT || 3000;\napp.listen(PORT, () => {\n console.log(`Server is running on port ${PORT}`);\n});" } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.