v-model component + vuex

————————————————————————
<template>
    <select @change=”on_change($event.target)” :value=”value”
        class=”form-control” name=”country” required>
        <option  v-for=”country in countries”   :value=”country.value”>
                {{country.name}}
        </option>
    </select>
</template>
methods: {
        on_change(target){
            this.$emit(‘input’, target.value)
        }
}
————————————————————–
<countries v-if=”countries_fetched” v-model=”country_value” />
computed: {
        country_value: {
           get: function(){
                return this.$store.getters[‘location/country_value’]
            },
            set: function(value){
                this.$store.commit(‘location/set_country_value’, value)
            }
}

axios interceptors – response errors

axios.interceptors.response.use(function (response) {
    // Do something with response data
    return response;
  }, 
  function (error) {
    const status = error.response ? error.response.status : null
    var config = error.config;
    console.log(config);
    console.log(status);
    error.config.__isRetryRequest = false;

    if (status === 500) { //500 Internal Server Error
        console.log('kartoti');
        error.config.__isRetryRequest = true;
        return axios(error.config);
    }

    if (status === 419) { //authorization
        window.location.href = "login";
    }

    if (status === 401) { //authorization
        window.location.href = "login";
        //axios(config);
        //axios.request(config);
    } 
    return Promise.reject(error);
  });
function retryFailedRequest (err) {
  if (err.status === 500 && err.config && !err.config.__isRetryRequest) {
    err.config.__isRetryRequest = true;
    return axios(err.config);
  }
  throw err;
}
axios.interceptors.response.use(undefined, retryFailedRequest);
Axios interceptors and asynchronous login
HAS DEMO
https://stackoverflow.com/questions/35900230/axios-interceptors-and-asynchronous-login

Authentication with Firebase

import firebase from 'firebase'
let config = {
  apiKey: "YOUR_API_KEY",
  authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
  databaseURL: "https://YOUR_PROJECT_ID.firebaseio.com",
  projectId: "YOUR_PROJECT_ID",
  storageBucket: "YOUR_PROJECT_ID.appspot.com",
  messagingSenderId: "YOUR_MESSAGING_SEND_ID"
};
let app;
firebase.initializeApp(firebase_config)
firebase.auth().onAuthStateChanged(function(user) {
  if (!app) {
    app = new Vue({
    })
  }
});

//----------- signup & login -------------- 
firebase.auth().createUserWithEmailAndPassword(email, password)
firebase.auth().signInWithEmailAndPassword(email, password)
//---------------------------------------------------------
https://medium.com/@anas.mammeri/vue-2-firebase-how-to-build-a-vue-app-with-firebase-authentication-system-in-15-minutes-fdce6f289c3c