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

    [SOLVED] Can't set data () inner value by one of method

    Help
    3
    8
    219
    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.
    • N
      nobilik last edited by nobilik

      Hi! Here is part of my scripts:

      export default {
        name: 'Login',
        data () {
          return {
            data: {
              body: {
                email: '',
                password: '',
                rememberMe: false,
                auth: {
                  profile: {} <---- ****This is a problem one****
                }
              }
            },
            isPwd: true,
            loading: false
          }
        },
        methods: {
          auth (network) {
            this.$hello(network).login({ scope: 'email', auth_type: 'rerequest' })
              .then((res) => {
                this.data.body.auth = res['authResponse']  <---- Here everything is ok
              })
            this.getProfile(network)
            this.$auth.socialLogin(this.data)
              .then((response) => {
                this.$router.push({ path: '/account' })
              })
              .catch((error) => {
                if (error.response) {
                  if (error.response.status === 401) {
                    this.$q.dialog({
                      message: this.$t('auth.login.verification_required')
                    })
                  } else if (error.response.status === 403) {
                    this.$q.notify({
                      message: this.$t('auth.login.invalid_credentials')
                    })
                  } else {
                    console.error(error)
                  }
                }
              })
          },
          getProfile (network) {
            this.$hello(network).api('me')
              .then((res) => {
                console.log(res) <---- Here I can see expected json
                this.data.body.auth.profile = res <--- And here is something wrong
                console.log(this.data) <--- No profile inside (((
              })
          },
      

      I have problem with populating of profile. I mark everything in my code. What I’m doing wrong? Thanks for help!

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        It should be this.body.auth.profile, shouldn’t it?

        Scott

        N 1 Reply Last reply Reply Quote 0
        • N
          nobilik @s.molinari last edited by

          @s-molinari but why? first upper one works this way…

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by s.molinari

            I have no idea why it works. But, data isn’t an available property on this as you are suggesting. See here.

            https://codesandbox.io/s/codesandbox-app-k12is

            Scott

            N 1 Reply Last reply Reply Quote 0
            • metalsadman
              metalsadman last edited by metalsadman

              @nobilik move your call to getprofile inside your first then at your auth method or use promise.all, or use async await so its more syncronizingly called. I suggest you read a bit about promises/async awaits.

              N 1 Reply Last reply Reply Quote 1
              • N
                nobilik @s.molinari last edited by

                @s-molinari I think you didn’t see data: {} inside data ()

                1 Reply Last reply Reply Quote 0
                • s.molinari
                  s.molinari last edited by

                  You are right. Never mind me then. 😊

                  Scott

                  1 Reply Last reply Reply Quote 0
                  • N
                    nobilik @metalsadman last edited by

                    @metalsadman Thanks, getprofile inside first then do the job

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