()
| 60 | } |
| 61 | |
| 62 | private async getData() { |
| 63 | if (!this.kitsuSlug) { |
| 64 | const kitsuRes = await helper.malToKitsu(this.malId, this.type); |
| 65 | try { |
| 66 | const relation = kitsuRes.data.find( |
| 67 | item => item.relationships.item.data.type === this.type, |
| 68 | ); |
| 69 | if (!relation) throw new NotFoundError(`No entry found for malId ${this.malId}`); |
| 70 | this.kitsuId = Number(relation.relationships.item.data.id); |
| 71 | kitsuRes.included.forEach(el => { |
| 72 | if (Number(el.id) === this.kitsuId) { |
| 73 | this.kitsuSlug = el.attributes.slug; |
| 74 | } |
| 75 | }); |
| 76 | if (!this.kitsuSlug) throw new NotFoundError(`No slug found for ${this.kitsuId}`); |
| 77 | } catch (e) { |
| 78 | throw new NotFoundError(e.message); |
| 79 | } |
| 80 | } |
| 81 | return this.apiCall( |
| 82 | 'GET', |
| 83 | `https://kitsu.app/api/edge/${this.type}?filter[slug]=${this.kitsuSlug}&include=characters.character,mediaRelationships.destination,categories&fields[categories]=slug,title&nsfw=true`, |
| 84 | {}, |
| 85 | true, |
| 86 | ).then(res => { |
| 87 | try { |
| 88 | res.data = res.data[0]; |
| 89 | // eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions |
| 90 | res.data.attributes.slug; |
| 91 | } catch (e) { |
| 92 | throw new NotFoundError(e.message); |
| 93 | } |
| 94 | |
| 95 | this.animeInfo = res; |
| 96 | }); |
| 97 | } |
| 98 | |
| 99 | private title() { |
| 100 | this.meta.title = helper.getTitle( |
no test coverage detected