簡體   English   中英

如何在 axios 中獲取當前的 URL?

[英]How Can I get current URL in axios?

我正在使用 Node.js 庫 axios 爬行 web。

Enter below emphasised URL, URL change https://steamcommunity.com/profiles/76561198141252368/games/?tab=all to https://steamcommunity.com/id/mungmung01/games/?tab=all .

https://steamcommunity.com/profiles/76561198141252368/games/?tab=all

我想在下面的源代碼中獲取當前 URL( https://steamcommunity.com/id/mungmung01/games/?tab=all )。 哪個可變返回電流URL?

const axios = require("axios");

const getHtml = async () => {
    try {
      return await axios.get("https://steamcommunity.com/profiles/76561198141252368/games/?tab=all");
   } catch (error) {
      console.error(error);
   }
};

getHtml()
    .then(
        console.log(/* Answer variable */)
    )
getHtml()
    .then((response) => {
        console.log(response.request.res.responseUrl);
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM