Skip to content
Advertisement

How can I input a number API as a string OR Where am I going to place toString()

So the code I’m trying to send is ( “buyPrice”:11.0 ). on the site (https://api.hypixel.net/skyblock/bazaar/product?key=a8394dae-033b-4ce5-a1a1-fb773cf2386f&productId=PORK). As you can see, the value inside the buyPrice is not a string but a number. And now, when I send the command into discord, it says “undefined”. But when I saw a code bellow that is valued is a string of the same website (“warning”: “This endpoint is deprecated and will soon be disabled.”). It worked flawlessly, so I’m thinking.

.toString()

but I don’t know where I am going to put the code in

my code is:

} else if (command === "bazaar") {
    let getBazaar = async () => {
        let response = await axios.get(
            'https://api.hypixel.net/skyblock/bazaar/product?key=a8394dae-033b-4ce5-a1a1-fb773cf2386f&productId=PORK'
        );
        let bazaar = response.data;
        return bazaar;
    };
    let bazaarValue = await getBazaar();
    console.log(bazaarValue)
    message.channel.send(`Buy Price: ${bazaarValue.buyPrice}`)

Advertisement

Answer

This doesn’t seem to be an error in your code. Just a legitimate warning from the API host stating that the url you are using (https://api.hypixel.net/skyblock/bazaar/product?key=a8394dae-033b-4ce5-a1a1-fb773cf2386f&productId=PORK) will be disabled.

As you mentioned where you are trying to send (“buyPrice”: 11.0), do read the comment by ippi, you need to see the json that the API is returning and find the value properly.

As for the message send command, (`Buy Price: ${bazaarValue.buyPrice}`) will always be a string, no matter what type bazaarValue.buyPrice is.

Advertisement