D
D
drawnofmymind2020-03-16 07:10:41
JavaScript
drawnofmymind, 2020-03-16 07:10:41

How to do authentication on vue.js using JSON file?

methods: {
        async submitForm(){
            const {login, pass} = this
            try {
              const response =  await axios.get("/data.json")
              if(response.data[1].login == login){
                   return (
                     localStorage.setItem('token', 'token'),
                     this.$router.push('/search')
                   )
              }else{
                    alert('пароль или логин не совпадают')
              }
            } catch (error) {
              console.log(error)
            }
        },
    },


Two users come from the server. If one of them is registered, redirect to the search page. Do I need to somehow bypass the array for the presence of at least one user (for example, using map)? Or is there another solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Tabakerka, 2020-03-18
@IvanTabakerka

Cool article on the organization of authorization in Vue.js. Maybe you will find something useful.
"Best practices" authorization for Vue

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question