Creating the API endpoint for GPT Answers
When our app is complete, we'll have a fully functional API endpoint that can return answers generated by the OpenAI API. But for now, we'll just create an endpoint that returns a placeholder response. Then, we'll test the endpoint using Postman and we'll come back later and finish coding it up.
Creating the API endpoint
To create the API endpoint, do the following:
- Open the
app.js
file that was created byexpress-generator
. The file should look like the following screenshot: - Edit line 7 and changeÂ
var usersRouter = require('./routes/users')
 to the following:var answerRouter = require('./routes/answer');
- Edit line 18 and changeÂ
app.use('/users', usersRouter);
 to the following:app.use('/answer', answerRouter);
After editing lines 7 and 18, the
app.js
file should...