The function IgDownloader is an asynchronous function that downloads Instagram data based on a given URL.

import { IgDownloader } from "ig-downloader";

/* The `const urls` array is storing two Instagram URLs. Each URL points to a specific Instagram post
or reel. These URLs are used in the `fetchInstagramData` function to fetch data from Instagram using
the `InstagramDownloader` function. The function iterates over each URL in the array, fetches data
for that URL, and then logs the Instagram data or any errors encountered during the process. */
const urls = [
"https://www.instagram.com/reel/DD3ja60ICGm/?utm_source=ig_web_copy_link",
"https://www.instagram.com/p/DD6_fC1TkcK/?utm_source=ig_web_copy_link",
];

const fetchInstagramData = async () => {
for (const url of urls) {
try {
console.log(`Fetching data for: ${url}`);
const data = await IgDownloader(url);
console.log("Instagram Data:", data);
} catch (error) {
console.error(
`Error fetching data for ${url}:`,
(error as Error).message
);
}
}
};

fetchInstagramData();
  • Parameters

    • url: string

      The url parameter in the IgDownloader function is a string that represents the URL of an Instagram post that you want to download.

    Returns Promise<XdtShortcodeMedia>

    The function IgDownloader is returning a Promise that resolves to an object of type XdtShortcodeMedia.