ByMykel / CSGO-API

An unofficial JSON API for Counter-Strike 2 in multiples languages. List of skins, cases, stickers, collections, collectibles, agents, graffiti, keys, patches and music kits.
https://bymykel.github.io/CSGO-API/
MIT License
255 stars 29 forks source link

Fix: CPH issue #105

Closed antal-k closed 5 months ago

antal-k commented 5 months ago
{
  item_name: '#CSGO_TournamentPass_cph2024',
  name: 'tournament_pass_cph2024',
  item_description: '#CSGO_TournamentPass_cph2024_Desc',
  image_inventory: 'econ/status_icons/pgl_pickem_2024_pass',
  prefab: 'cph2024_tournament_pass_prefab cph2024_tournament_steamtv_items',
  object_id: '4916',
  item_name_prefab: undefined,
  item_description_prefab: undefined,
  used_by_classes: undefined
}
TypeError: Cannot read properties of null (reading 'toLowerCase')
    at getRarityColor (file:///home/scripts/cs2-item-parser/utils/index.js:404:13)
    at parseItem (file:///home/scripts/cs2-item-parser/services/collectibles.js:118:11)
    at Array.map (<anonymous>)
    at getCollectibles (file:///home/scripts/cs2-item-parser/services/collectibles.js:141:4)
    at processUpdate (file:///home/scripts/cs2-item-parser/index.js:217:4)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SteamUser.<anonymous> (file:///home/scripts/cs2-item-parser/index.js:329:2)
ByMykel commented 5 months ago

Thank you very much ❤️

antal-k commented 5 months ago

Maybe it will be better to do this: @ByMykel

if (key.includes("tournament_journal_prefab")) {
    return "rarity_ancient";
}

if (key.includes("tournament_pass_prefab")) {
    return "rarity_common";
}

if (key.includes("_coin")) {
    return "rarity_ancient";
}