Installation

MQL is available as :
npm install @microlink/mql --save
It has been designed to be consumed in different ways, one of the most common being from Node.js using CommonJS:
const mql = require('@microlink/mql')

const { data } = await mql('https://kikobeats.com', {
  data: {
    avatar: {
      selector: '#avatar',
      type: 'image',
      attr: 'src'
    }
  }
})

console.log(
  `The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})`
)
It's ready to be consumed as ESM:
import mql from '@microlink/mql'

const { data } = await mql('https://kikobeats.com', {
  data: {
    avatar: {
      selector: '#avatar',
      type: 'image',
      attr: 'src'
    }
  }
})

console.log(
  `The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})`
)
Last but not least, it can be loaded as UMD in any browser:
<script src="https://cdn.jsdelivr.net/npm/@microlink/mql@latest/dist/mql.min.js"></script>
<script>
  mql('https://kikobeats.com', {
    data: {
      avatar: {
        selector: '#avatar',
        type: 'image',
        attr: 'src',
      }
    }
  }).then(({data}) => {
    console.log(`The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})`)
  })
</script>
I case you need to consume it using UMD, keep in mind the dependency is not included with the build bundle.
Although it's , we recommend use CDN for that purpose, it will only load polyfill if fetch is not globally detected.
<script>
  crossorigin="anonymous"
  src="https://polyfill.io/v3/polyfill.min.js?features=fetch">
</script>