Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is role the of url in async function in web scrapping

I am working on web scrapping and I came across one scenario where I am get confused about arrow key function,I am unable to understand why url is used twice and how it is actual working, I know it is advanced javascript but I need some explanation to understand this completely.

first Url in arrow function:

const fethHtml = async url => {

Second url pass in axios.get

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

await axios.get(url);

const fethHtml = async url => {

const axios = require("axios").default;

const fethHtml = async url => {
  try {
    const { data } = await axios.get(url);
    return data;
  } catch {
    console.error(
      `ERROR: An error occurred while trying to fetch the URL: ${url}`
    );
  }
};

My question is what url is indicating here is it variable or function and why it is called twice, I didn’t found any explanation anywhere.

>Solution :

const fethHtml = async url => {

url is just arguments. (ex:google.com)

then pass the arguments to axios to get resposne.

await axios.get(url);

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading