From 30743a11cfde0c670e71fe6959cb2c86463f9013 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 23 Apr 2024 22:46:18 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Refactored=20getIssuesForVolume?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/comicvine.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/comicvine.service.ts b/services/comicvine.service.ts index d645b69..595ec0b 100644 --- a/services/comicvine.service.ts +++ b/services/comicvine.service.ts @@ -2,7 +2,6 @@ import { Service, ServiceBroker, Context } from "moleculer"; import axios from "axios"; -import delay from "delay"; import { isNil, isUndefined } from "lodash"; import { fetchReleases, FilterTypes, SortTypes } from "comicgeeks"; import { matchScorer, rankVolumes } from "../utils/searchmatchscorer.utils"; @@ -496,19 +495,20 @@ export default class ComicVineService extends Service { async handler(ctx: Context<{ volumeId: number }>) { const { volumeId } = ctx.params; - const issuesUrl = `${CV_BASE_URL}issues/?api_key=${process.env.COMICVINE_API_KEY}&filter=volume:${volumeId}&format=json&field_list=id,name,issue_number,description,image`; - + const issuesUrl = `${CV_BASE_URL}issues/?api_key=${process.env.COMICVINE_API_KEY}`; try { - const response = await axios({ - url: issuesUrl, - method: "GET", + const response = await axios.get(issuesUrl, { params: { - limit: "100", + api_key: process.env.COMICVINE_API_KEY, + filter: `volume:${volumeId}`, format: "json", + field_list: + "id,name,image,issue_number,cover_date,description", + limit: 100, // Adjust the limit as per your requirement }, headers: { Accept: "application/json", - "User-Agent": "ThreeTwo", + "User-Agent": "ThreeTwo", // It's good practice to define a User-Agent, especially when using APIs that might track request sources }, });