My glitch project name is Munari, i have some error when get data from https://www.instagram.com/${username}/?__a=1. the console send Type Error: can’t read property ‘user’ of undefined. I use axios and discord.js-light. but when i run from localhost, it’s work. how to fix it?
I wasn’t able to find the project at glitch.com/edit/#!/munari
. Could you share a link?
Or, could you share the code that fetches the instagram link? You could have a malformed ENV variable or something similar returning errors.
const { MessageEmbed } = require('discord.js-light')
const axios = require('axios')
module.exports = {
name: "instagram",
aliases: ["insta", "ig"],
category: "",
descriptions: "Display instagram information",
usage: "instagram <username>",
options: [""],
cooldown: "5",
ownerOnly: true,
async run(client, message, args) {
try {
const username = args[0];
const response = await axios.get(`https://www.instagram.com/${username}/?__a=1`);
const { data } = response;
const get = data.graphql
const fullname = get.full_name
const userig = get.username
const bio = get.biography === null ? "None" : get.biography
const follower = get.edge_followed_by.count
const following = get.edge_follow.count
const priv = get.is_private ? "Yes 🔒" : "No 🔓"
let e = new MessageEmbed()
.setColor(0x0099ff)
.setTitle(`${fullname}`)
.setURL(`https://www.instagram.com/${username}`)
.setDescription(`${userig} \n ${follower}`)
await message.channel.send(e)
} catch (error) {
message.channel.send("Cannot find username");
console.log(error)
}
}
}
async run(client, message, args) {
const username = args[0];
const response = await axios.get(`https://www.instagram.com/${username}/?__a=1`);
//...
}
How are you using this function? Try console.logging args
and see what it looks like - args[0] might not be a valid username.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.