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
    1. Home
    2. blini
    B
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 0
    • Groups 0

    blini

    @blini

    0
    Reputation
    144
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    blini Follow

    Latest posts made by blini

    • RE: Transitions between pages, routes, vues

      thank you

      posted in Help
      B
      blini
    • RE: [How to] load external dependencies (CDN) ASYNC

      @benoitranque thanks, ur code is broken, I just fixed it

      
      let api = {}
      
      export default {
        config: function configApi(id, url) {
          if (!api[id]) {
            api[id] = {
              config: {
                id,
                url
              }
            }
          }
          else {
            // atempted creating same api multiple times
            // error code goes here
            console.error(`Atempted to create API ${id} multiple times`)
          }
        },
        load: function loadApi(id) {
          if (api[id]) {
            if (!api[id].promise) {
              if (!document.getElementById(api[id].config.id)) {
                api[id].promise = new Promise((resolve, reject) => {
                  let script = document.createElement('script')
                  script.src = api[id].config.url
                  script.async = true
                  script.id = api[id].config.id
                  script.onload = () => {
                    resolve()
                  }
                  script.onerror = (err) => {
                    reject(err)
                    // not sure about this part. ESLint wants error to be passed, not sure if doing it properly
                  }
                  document.body.appendChild(script)
                })
              }
              else {
                // atempted to create api but id already exists
                // error code
                console.error(`Make sure the id ${id} is unique and is not used anywhere else in your app.`)
              }
            }
            return api[id].promise
          }
          else {
            // api has not been configured
            // error
            console.error(`API ${id} does not exist. Have you configured it in main.js?`)
          }
        }
      }
      
      posted in Show & Tell
      B
      blini