No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    how can i set a default header with the jwt-token in all the request after login

    Help
    4
    7
    1361
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      thamibn last edited by

      0_1544705768239_Capture.PNG

      i have tried the above on the picture however is saying it can find $store.

      J 2 Replies Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Are you using Vuex? Is it installed properly?

        Scott

        T 1 Reply Last reply Reply Quote 0
        • J
          jannerantala @thamibn last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • J
            jannerantala @thamibn last edited by

            @thamibn I always set the Axios header after the login. Before the login all requests are made without the Bearer token:

            this.$http.post('/login', {
            username: this.email,
            password: this.password
            })
            .then(res=> {
            localStorage.token = res.token;
            this.$http.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.token;
            })
            
            T 1 Reply Last reply Reply Quote 1
            • K
              KevinYang last edited by KevinYang

              if you use axios, you can try this.

              import axios from 'axios'
              setAxiosHeaders (token) {
                    axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
              }
              
              1 Reply Last reply Reply Quote 1
              • T
                thamibn @s.molinari last edited by

                @s-molinari yes it is installed properly

                1 Reply Last reply Reply Quote 0
                • T
                  thamibn @jannerantala last edited by

                  @jannerantala AND @KevinYang thanks you so much guys this worked!!!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post