Postman returning <pre>Cannot GET /usuario</pre>

Asked

Viewed 16 times

0

I’m following a course of Node.js with refresh tokens and in some part of the code I started getting this error and I couldn’t figure out what might be causing it. I followed the course and my requests always worked well, but there was a class where the tutor needed to modify some parts of the code and from there I started to receive the errors. I took the files from Github to see what changed and modified my code as well.

In Postman I have this error message

<head>
    <meta charset="utf-8">
    <title>Error</title>
</head>

<body>
    <pre>Cannot GET /usuario</pre>
</body>

</html>

On my VS Code terminal the API is working normally. inserir a descrição da imagem aqui

My server.js file is

require('dotenv').config()

const app = require('./app');
const port = 3000;
require('./')
require('./database');
require('./redis/blocklist');

const routes = require('./rotas');
routes(app);

app.listen(port, () => console.log("A API está conectada!"))

My.js route code is const posts = require('./src/posts'); const usuarios = require('. /src/usuarios');

module.exports = app => {
    posts.rotas(app);
    usuarios.rotas(app);
};

My user-route code.js is

const usuariosControlador = require('./usuarios-controlador');
const middlewaresAutenticacao = require('./middlewares-autenticacao');


module.exports = (app) => {
    app.route('/usuario/login')
    app.post(middlewaresAutenticacao.local, usuariosControlador.login);

    app.route('/usuario/logout')
    app.get(middlewaresAutenticacao.bearer, usuariosControlador.logout);

    app.route('/usuario')
    app.post(usuariosControlador.adiciona)
    app.get(usuariosControlador.lista);

    app.route('/usuario/:id')
    app.delete(middlewaresAutenticacao.bearer, usuariosControlador.deleta);
};

My code on Github is: https://github.com/Stephani0106/Seguranca-com-NodeJS

And my tutor’s course code: https://github.com/alura-cursos/blog-do-codigo-2

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.