Skip to content

Instantly share code, notes, and snippets.

@kavikumarN
Forked from sivasankars/app.js
Created February 9, 2022 06:00
Show Gist options
  • Save kavikumarN/ef3e8579b5197530e951c5c87851c026 to your computer and use it in GitHub Desktop.
Save kavikumarN/ef3e8579b5197530e951c5c87851c026 to your computer and use it in GitHub Desktop.
Firebase Dynamic Links With REST APIs On Node.js - Create a short link from a long link
const request = require('request');
const API_KEY = 'xxx';
const body = {
'longDynamicLink': 'https://niralar.page.link/?link=http://niralar.com/building-rest-apis-with-swagger-on-node-js/'
}
request({
url: `https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=${API_KEY}`,
method: 'POST', json: true, body
}, function (error, response) {
if (error) {
console.log('Error :', error)
} else {
if (response && response.statusCode !== 200) {
console.log('Error on Request :', response.body.error.message)
} else {
console.log('Dynamic Link :', response.body);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment