Skip to content

Instantly share code, notes, and snippets.

@sivasankars
Created January 31, 2020 07:19
Show Gist options
  • Save sivasankars/52d5cd2d95c5d462fbf7a38a3a4b5e9a to your computer and use it in GitHub Desktop.
Save sivasankars/52d5cd2d95c5d462fbf7a38a3a4b5e9a 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