K
K
Konstantin2019-03-12 19:41:43
Vue.js
Konstantin, 2019-03-12 19:41:43

Vue, for some reason I get 404 from axios?

Good evening.
I can't figure out why I'm getting an error in the console, does anyone know?
POST localhost:5000/api/auth/login 404 (Not Found)
login.vue

Vue.axios.post('/auth/login', this.user)
                    .then((response) => {
                        console.log("Logged in")
                        this.userLog = res.data
                    })
                    .catch((errors) => {
                        console.log("Cannot login")   <--- Эта строка показывается в консоле
                    })

server/app.js
// localhost:5000/api/auth/login
app.use('/api/auth', authRoutes)

server/router/auth.js
// localhost:5000/api/auth/login
router.post('/login', controller.login)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GLaDosSystem, 2019-03-12
@GLaDosSystem

So you wrote "/auth/login" in the first line, shouldn't it be "/api/auth/login"?

K
Konstantin, 2019-03-12
@dragon11

Through Postman it works, I get a token, through axios 404

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question