Using json online


So, I’m trying to make something like however, when using my code with a discord bot, it isn’t working.. It makes me wonder if you can host json things online directly by using the below code:

document.body.innerHTML = "<pre style=\"word-wrap: break-word; white-space: pre-wrap;\">{\"file\":\"https:\\/\\/"+domain+"\\/images\\/hug\\/"+item+"\"}</pre>";

Furthermore, my bot code is:

const { MessageEmbed } = require('discord.js');
const axios = require('axios');
const {get} = require("snekfetch");

const embed = new MessageEmbed()
        .setDescription("Loading...") => {
    get('').then(response => {
        }, 1500);

My website is working perfectly and is showing exactly as in However, it still doesn’t work. Please lmk how or why this is happening.

P.S I didn’t include the modules.export part in the bot code cuz, I thought it was extra.

P.P.S The following is my current output: This


4 thoughts on “Using json online”

  1. If you want to provide data in a JSON format on your endpoint then just provide the JSON part, no need to put it in an HTML. If you put your JSON inside HTML like a string, then when you do get(<your url>) you’ll get the entire HTML code with the embedded JSON, and so response.file doesn’t work.

    The reason why shows up as being embedded within HTML is because the browser detects that it is a JSON file and hence it does the embedding automatically. Here is the RAW response from that URL when you try to make the request using wget on the command line:

    $ wget --no-check-certificate
    $ cat meow

    As you can see, there’s no HTML around it. It’s pure JSON.

    To verify that this is indeed the case, log the response you get from your url:

    get('').then(response => {

    Unrelated: anyone else appreciate the cat meow coincidence here?


Leave a Comment