## Table of Contents

- [evaluate](#evaluate)

---

[](https://microlink.io/docs/api/getting-started/overview)

[API](https://microlink.io/docs/api/getting-started/overview)

[](https://microlink.io/docs/guides)

GUIDES

[](https://microlink.io/docs/mql/getting-started/overview)

MQL

[](https://microlink.io/docs/sdk/getting-started/overview)

SDK

[](https://microlink.io/docs/cards/getting-started/overview)

CARDS

## evaluate

It evaluates the JavaScript stringified value provided inside the browser context over the target URL, returning the result.

It's quite similar to [selector](https://microlink.io/docs/mql/data/selector), but designed to specify the value to be obtained in a JavaScript-like way.

``` js
const mql = require('@microlink/mql')

const getNextVersion = url =>

  mql(url, {

    data: {

      version: {

        evaluate: 'window.next.version',

        type: 'string'

      }

    }

  })

const { data } = await getNextVersion('https://vercel.com')

console.log(`Next.js version is: ${data.version}`)
```

You can combine evaluate with types for data correcteness.

It can evaluate anything browser compatible in the JavaScript context.

``` js
const mql = require('@microlink/mql')

const getExcerpt = url =>

  mql(url, {

    data: {

      excerpt: {

        evaluate: async () => {

          const response = await window.fetch(

            'https://cdn.jsdelivr.net/npm/@mozilla/readability/Readability.js'

          )

          const script = await response.text()

          window.eval(script)

          const reader = new window.Readability(window.document)

          return reader.parse().excerpt

        },

        type: 'string'

      }

    }

  })

const { data } = await getExcerpt(

  'https://levelup.gitconnected.com/how-to-load-external-javascript-files-from-the-browser-console-8eb97f7db778'

)

console.log(data.excerpt)
```