-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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