-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
QuestionsAndAnswersAPI/server/controllers/controller.js
Lines 9 to 40 in 9e8ff4f
| model.getQuestions(product_id, count, page, (err, questions) => { | |
| if (err) { | |
| console.log(err); | |
| res.status(400).send(err); | |
| } | |
| res.status(200).send(questions); | |
| }); | |
| }, | |
| getAnswers: (req, res) => { | |
| let question_id = req.params.question_id; | |
| let count = req.query.count; | |
| let page = req.query.page; | |
| model.getAnswers(question_id, count, page, (err, answers) => { | |
| if (err) { | |
| res.status(400).send(); | |
| } else { | |
| res.status(200).send(answers); | |
| } | |
| }); | |
| }, | |
| addQuestion: (req, res) => { | |
| const question = req.body; | |
| console.log(req.body); | |
| model.addQuestion(question, (err, data) => { | |
| if (err) { | |
| res.status(400).send(); | |
| } else { | |
| res.status(200).send('successfully posted question!'); | |
| } | |
| }); | |
| } |
The following applies to lines 12, 24, 35:
The error code 400 indicates that the request from the client was malformed or incorrect in some way. If the error was not caused by a bad request, then a different response code may be more appropriate (404 is often a good choice for GET requests, and 422 or 409 may be a good choice for POST requests).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels