Welcome folks today in this blog post we will be fetching or extracting facebook user id
from username in javascript. All the source code of the application is given below.
Get Started
In order to get started we need to install this library get-facebook-id
by using the npm command a shown below
npm i get-facebook-id
Now after installing this library we need to create index.js
file and copy paste the following code
index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
const facebookIdOf = require('facebook-id-of'); // using callback facebookIdOf('an_user', function (err, facebookId) { if (err) return console.error(err); console.log(facebookId); }); // using promise facebookIdOf('an_user') .then((facebookId) => { console.log(facebookId); }) .catch((err) => { console.error(err); }); // using async/await async function () { try { const facebookId = await facebookIdOf('an_user'); console.log(facebookId); } catch (err) { console.error(err); } } |
Getting started
CLI usage
npm i -g facebook-id-of