From 665e166a6ef656a198bd78936a4a43399514fad8 Mon Sep 17 00:00:00 2001 From: Kayo Souza Date: Sat, 13 Apr 2024 22:54:53 -0300 Subject: [PATCH] Minor bug fix --- package.json | 2 +- src/Downloader.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c86e035..2e897de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Kayo Souza", "name": "insta-downloader", - "version": "3.3.2", + "version": "3.3.3", "description": "An application to download content from Instagram", "main": "src/index.js", "scripts": { diff --git a/src/Downloader.js b/src/Downloader.js index 27f2497..b70fcd6 100644 --- a/src/Downloader.js +++ b/src/Downloader.js @@ -235,12 +235,17 @@ export default class Downloader { responseType: "json" }) - if(typeof response?.data === "object" && "user" in response.data.data){ - const { user } = response.data.data - return user + if(typeof response?.data === "object"){ + const { data } = response.data + + if(data && "user" in data){ + return data.user + } + + throw new Error(`Failed to get user: ${username}`) } - return null + throw new Error(`User not found: ${username}`) } /** @param {string} username */ async GetUserId(username){