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
Generate 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. - Assistant
{ "name": "saveProductToWishlist", "schema": { "type": "string", "code": "const express = require('express');\nconst bodyParser = require('body-parser');\n\nconst app = express();\napp.use(bodyParser.json());\n\nlet wishlists = {};\n\napp.post('/api/wishlist', (req, res) => {\n const { userId, productId } = req.body;\n if (!userId || !productId) {\n return res.status(400).send('userId and productId are required.');\n }\n if (!wishlists[userId]) {\n wishlists[userId] = [];\n }\n if (!wishlists[userId].includes(productId)) {\n wishlists[userId].push(productId);\n }\n res.status(200).send({ userId, wishlist: wishlists[userId] });\n});\n\nconst PORT = process.env.PORT || 3000;\napp.listen(PORT, () => {\n console.log(`Server is running on port ${PORT}`);\n});\n" } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.