Skip to content

Instantly share code, notes, and snippets.

@sivasankars
Created January 31, 2020 07:18
Show Gist options
  • Save sivasankars/2f32f3f25088e71413cd274b2d01115f to your computer and use it in GitHub Desktop.
Save sivasankars/2f32f3f25088e71413cd274b2d01115f 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 = {
'dynamicLinkInfo': {
'domainUriPrefix': '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