0

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

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.

2
  • 1
    Variables are not called. They're created and referenced. Commented Jan 10, 2022 at 9:11
  • 1
    async url => { creates a variable to be used inside the fetchHtmlz function, whereas axios.get(url)` passes that variable into the axios.get function. This is not unusual. Commented Jan 10, 2022 at 9:14

1 Answer 1

1

const fethHtml = async url => {

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

then pass the arguments to axios to get resposne.

await axios.get(url);

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.