Fetching store_date until a specific year

Avatar image for andrenormanlang
andrenormanlang

6

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Does anyone know if it is possible the fetch issues until a specific store date? I am trying to fetch until the end of 2026 since there are errors in the database with some issues data from 2027 onwards.

I have been trying the following but no success

import { NextApiRequest, NextApiResponse } from 'next';

const axios = require('axios');

// Fetch latest comic issues from Comic Vine API

async function fetchLatestIssues(page: number, limit: number) {

const API_KEY = process.env.COMIC_VINE_API_KEY;

const BASE_URL = 'https://comicvine.gamespot.com/api';

const endDate = '2026-12-31';

// Set the end date to December 31, 2026

try { const response = await axios.get(`${BASE_URL}/issues/`, {

params: {

api_key: API_KEY,

format: 'json',

sort: 'store_date:desc', filter: `store_date:<=${endDate}`,// Add a filter for store_date

limit: limit,

offset: (page - 1) * limit } });

// Depending on the response structure, adjust the return statement

return response.data.results;// assuming 'results' contains the issues

} catch (error) {

console.error('Error fetching data from Comic Vine API:', error);

return null;

}

}

export default async function handler(

req: NextApiRequest,

res: NextApiResponse

) {

const page = parseInt(req.query.page as string) || 1;

const limit = parseInt(req.query.limit as string) || 6;

const issues = await fetchLatestIssues(page, limit);

if (issues) {

res.status(200).json(issues);

} else {

res.status(500).json({ message: 'Error fetching comics' });

}

}

Avatar image for flips
flips

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By flips

I don't believe <= is valid, but I'm not positive. I think you need to do a from and to date like this: filter=store_date:2024-01-01|2024-01-05