Giter Site home page Giter Site logo

Comments (7)

biigpongsatorn avatar biigpongsatorn commented on August 9, 2024

@heihachi88 This example code is true. Try to check your fetchData function again. It return Promise right ?

from vue-element-loading.

avxkim avatar avxkim commented on August 9, 2024
    fetchData: _.debounce(function (offset = false) {
      // console.log(offset)
      axios.get(globalConfig.ORDERS_URL, {
        withCredentials: true,
        headers: {
          'Authorization': auth.getAuthHeader()
        }
      })
        .then((resp) => {
          this.req = resp.data
          // console.log(resp)
        })
        .catch((err) => {
          console.log(err)
          if (err.response.status === 403) {
            auth.logout()
          }
        })
    }, 500),

from vue-element-loading.

biigpongsatorn avatar biigpongsatorn commented on August 9, 2024

@heihachi88
You must set async/await in your function.

fetchData: async _.debounce(async (offset = false) => {
   await axios.get...
}, 500)

from vue-element-loading.

avxkim avatar avxkim commented on August 9, 2024

With await it's going to wait until i get response from get reqeust?

from vue-element-loading.

biigpongsatorn avatar biigpongsatorn commented on August 9, 2024

@heihachi88 Yes

from vue-element-loading.

avxkim avatar avxkim commented on August 9, 2024

it's not possible to set await inside a function, as you described above, it returns an error:

Syntax Error: await is a reserved word (311:6)

from vue-element-loading.

biigpongsatorn avatar biigpongsatorn commented on August 9, 2024

This is not problem of vue-element-loading, Your problem is async/await function. You can learn more about it here.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

from vue-element-loading.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.