I am trying to send a get request from the client to the server in order to later take the necessary data from the database. For XMLHttpRequests I use the axios library. The problem is that the request is not sent, the console displays: GET http: // localhost: 3000 / items 404 (Not Found). Error: Request failed with status code 404. What could be the error?
Клиентская часть: <script> export default { data(){ return{ items: [] } }, created: function() { this.fetchItems(); }, methods: { fetchItems (){ let uri = '/items'; this.axios.get(uri).then((response) => { this.items = response.data.items; }); } } } </script> Server part:
var express = require('express'); var app = express(); var itemRoutes = express.Router(); itemRoutes.route('/items').get(function (req, res) { res.send('GET request to the homepage'); });