Created
January 31, 2020 07:19
-
-
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
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