diff --git a/index.js b/index.js index a9b4205..2a22a8c 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,10 @@ const p = require('phin'); const target = process.argv[process.argv.length - 1]; +const domain = process.env.domain; + const key = process.env.API_KEY; +const baseDomain = process.env.BASE_DOMAIN || "https://kutt.it"; if (!key) { return console.log('Please set an API key first.'); @@ -17,7 +20,7 @@ function getErrorMessage(message) { (async function() { try { const { body = {} } = await p({ - url: 'https://kutt.it/api/url/submit', + url: `${baseDomain}/api/v2/links`, method: 'POST', data: { target }, core: { @@ -28,7 +31,7 @@ function getErrorMessage(message) { }, parse: 'json' }); - const message = body.shortUrl || getErrorMessage(body.error) + const message = body.link || getErrorMessage(body.error) console.log(message) } catch (error) { console.log(error.message);