Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda