goorl

Shorten urls with goo.gl

Usage no npm install needed!

<script type="module">
  import goorl from 'https://cdn.skypack.dev/goorl';
</script>

README

Build Status js-standard-style

goorl

Shortens url with goo.gl

Installation

From npm

$ npm i goorl

Usage

Required inputs

key Your google API key

url The URL you want to shorten

Promises

const goorl = require('goorl')
const options = {
  key: 'your-google-api-key',
  url: 'http://www.telemark.no/Planer/Regional-planstrategi/Offentlig-ettersyn-ny-regional-planstrategi'
}

goorl(options)
  .then(url => console.log(url))
  .catch(error => console.error(error))

Callbacks

const goorl = require('goorl')
const options = {
  key: 'your-google-api-key',
  url: 'http://www.telemark.no/Planer/Regional-planstrategi/Offentlig-ettersyn-ny-regional-planstrategi'
}

goorl(options, (error, url) => {
  if (error) {
    console.error(error)
  } else {
    console.log(url)
  }
})

License

MIT