Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
Axios created string returns 403 forbidden since the URL is broken but works fine hardcoded string

Axios created string returns 403 forbidden since the URL is broken when the URL is made by combining several strings.

Here is an example: This works fine:

const inventory = await axios.get("http://steamcommunity.com/inventory/76561198164672016/730/2?l=english&count=5000");

It returns the correct results.

But when using the same URL, just combining different values, it does not work.

const testId = 76561198164672016;
const path = "http://steamcommunity.com/inventory/"+testId.toString()+"/730/2?l=english&count=5000"
    const inventoryWithPath = await axios.get(path);

This returns an error. I don't understand how this can happen when the strings are the same... Here is the full code.

const axios = require('axios').default;
const testId = 76561198164672016;


async function getInventory(){
    try{

    //invetory works fine and returns correct values
    const inventory = await axios.get("http://steamcommunity.com/inventory/76561198164672016/730/2?l=english&count=5000");

    //Even though this has the same URL it returns an error. Why and how can I request based on the path?
    const path = "http://steamcommunity.com/inventory/"+testId.toString()+"/730/2?l=english&count=5000"
    const inventoryWithPath = await axios.get(path);
    
    //console.log(inventoryWithPath)
    console.log(inventory)
    return inventory;
    }
    catch(err){
        console.log(err);
        console.log("Error happened")
    }
}
module.exports={getInventory}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As suggested in the comments, the reason your code isn't working is because testId > Number.MAX_SAFE_INTEGER. What you can do to solve this is use BigInt like this:

const path = "http://steamcommunity.com/inventory/" + BigInt(testId).toString() + "/730/2?l=english&count=5000"

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda