We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Could you provide the rest api spec?
I mean only the expected request and response
Thanks
The text was updated successfully, but these errors were encountered:
I achieved to recreate the api
npm install express body-parser cors
var express = require('express'); var app = express(); var bodyParser = require('body-parser'); var port = process.env.PORT || 5000; var cors = require('cors'); var tasks = [{_id: "f98decd1-0899-444b-a33f-0efc611e1b4d", title: "foo", completed: true}]; app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); app.use(cors()); app.get('/api/v1/tasks', function(req, res) { return res.json({"tasks": tasks}); }); app.post('/api/v1/tasks/', function(req, res) { tasks.push({...req.body, _id: uuidv4()}) return res.json({"code": 200000, message: "success"}); }); app.patch('/api/v1/tasks/:id', function(req, res) { var foundIndex = tasks.findIndex(x => x._id == req.params.id); tasks[foundIndex] = req.body; return res.json({"code": 200000, message: "success"}); }); app.delete('/api/v1/tasks/:id', function(req, res) { var foundIndex = tasks.findIndex(x => x._id == req.params.id); if(foundIndex<0) { return res.json({"code": 404000, message: "No todo found"}); } tasks.splice(foundIndex, 1) return res.json({"code": 200000, message: "success"}); }); function uuidv4() { return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c => (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16) ); } app.listen(port); console.log(`api mock is ready at ${port}`)
Sorry, something went wrong.
No branches or pull requests
Could you provide the rest api spec?
I mean only the expected request and response
Thanks
The text was updated successfully, but these errors were encountered: