Could not parse response body as JSON #2

Open
opened 1 year ago by clarity · 0 comments
clarity commented 1 year ago

Hi today i came beceaue i have an error of encoding with your configs with two example one who works with no error one who are glitch. With my code of course.
Thanks for your help <3

const { Client,GatewayIntentBits} = require('discord.js');
const client = new Client({
	intents: [
		GatewayIntentBits.Guilds,
		GatewayIntentBits.GuildMessages,
		GatewayIntentBits.MessageContent,
		GatewayIntentBits.GuildMembers,
	],
});
const axios = require("axios");
const Promise = require("bluebird");
const getJson = require("axios-get-json-response");

client.on('messageCreate', async (message) => {
  if (message.content.startsWith('!doge')){
    const a = Math.random() * (5-0) + 1
    var b = parseInt(a);
    console.log(b)
    const { data } = await axios.get(
      `https://dogechain.info/chain/Dogecoin/q/addressbalance/DQzs4yzLoR3UJ3YdCRSD7eEeW3kv5gdca2`
    );

      Promise.try(() => {
        return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd", getJson.axiosConfiguration).then((response) => {
          console.log(response)
          let parsedJsonbalance = getJson.parse(response);


          const dataprice = (parsedJsonbalance.totalAssetInUsd)

    const checkprice = data * dataprice

    message.reply(`Le solde du wallet dogecoin simcash est ${checkprice}usd`)

    if (b == 5) {
      message.reply(`N'hésitez pas a mettre mon code d'affiliation simcash XMHX3 cela me soutiens énormement <3 clarity`)
    }
  })})}})

client.on('messageCreate', async (message) => {
    if (message.content.startsWith('!usdt')){
      const a = Math.random() * (5-0) + 1
      var b = parseInt(a);
      console.log(b)
      Promise.try(() => {
        return axios.get("https://apilist.tronscanapi.com/api/account/token_asset_overview?address=TTiLvHXVBRHuF6xDP6Y3tZs5XPvkpYSReA", getJson.axiosConfiguration);
    }).then((response) => {
        console.log(response)
        let parsedJsonbalance = getJson.parse(response);

        const data = (parsedJsonbalance.totalAssetInUsd)

        console.log(data)
  
      message.reply(`Le solde du wallet Usdt Tron simcash est ${data} usd`)

      if (b == 5) {
        message.reply(`N'hésitez pas a mettre mon code d'affiliation simcash XMHX3 cela me soutiens énormement <3 clarity`)
      }
    })}})
Hi today i came beceaue i have an error of encoding with your configs with two example one who works with no error one who are glitch. With my code of course. Thanks for your help <3 ```js const { Client,GatewayIntentBits} = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, ], }); const axios = require("axios"); const Promise = require("bluebird"); const getJson = require("axios-get-json-response"); client.on('messageCreate', async (message) => { if (message.content.startsWith('!doge')){ const a = Math.random() * (5-0) + 1 var b = parseInt(a); console.log(b) const { data } = await axios.get( `https://dogechain.info/chain/Dogecoin/q/addressbalance/DQzs4yzLoR3UJ3YdCRSD7eEeW3kv5gdca2` ); Promise.try(() => { return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd", getJson.axiosConfiguration).then((response) => { console.log(response) let parsedJsonbalance = getJson.parse(response); const dataprice = (parsedJsonbalance.totalAssetInUsd) const checkprice = data * dataprice message.reply(`Le solde du wallet dogecoin simcash est ${checkprice}usd`) if (b == 5) { message.reply(`N'hésitez pas a mettre mon code d'affiliation simcash XMHX3 cela me soutiens énormement <3 clarity`) } })})}}) client.on('messageCreate', async (message) => { if (message.content.startsWith('!usdt')){ const a = Math.random() * (5-0) + 1 var b = parseInt(a); console.log(b) Promise.try(() => { return axios.get("https://apilist.tronscanapi.com/api/account/token_asset_overview?address=TTiLvHXVBRHuF6xDP6Y3tZs5XPvkpYSReA", getJson.axiosConfiguration); }).then((response) => { console.log(response) let parsedJsonbalance = getJson.parse(response); const data = (parsedJsonbalance.totalAssetInUsd) console.log(data) message.reply(`Le solde du wallet Usdt Tron simcash est ${data} usd`) if (b == 5) { message.reply(`N'hésitez pas a mettre mon code d'affiliation simcash XMHX3 cela me soutiens énormement <3 clarity`) } })}}) ```
7.7 KiB
8.1 KiB
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joepie91/axios-get-json-response#2
Loading…
There is no content yet.