Commit 9593fdee authored by nanahira's avatar nanahira

ignore ssl cert

parent ff610fe5
import Base from "./base"; import Base from "./base";
import axios from "axios"; import axios, { AxiosInstance } from "axios";
import { Card } from "./dbreader"; import { Card } from "./dbreader";
import { Agent } from "https";
export class CNOCGFetcher extends Base { export class CNOCGFetcher extends Base {
static async fetchOnce() { static async fetchOnce() {
...@@ -8,9 +9,18 @@ export class CNOCGFetcher extends Base { ...@@ -8,9 +9,18 @@ export class CNOCGFetcher extends Base {
await fetcher.init(); await fetcher.init();
return await fetcher.fetch(); return await fetcher.fetch();
} }
axiosInstance: AxiosInstance;
async init() {
await super.init();
this.axiosInstance = axios.create({
httpsAgent: new Agent({
rejectUnauthorized: false
})
})
}
async fetch(): Promise<Card[]> { async fetch(): Promise<Card[]> {
this.log.debug(`Started fetching from CNOCG source...`); this.log.debug(`Started fetching from CNOCG source...`);
const allCardStrings: string[] = (await axios.get("https://api.tcgcardgame.com/api/cards/sc", { const allCardStrings: string[] = (await this.axiosInstance.get("https://api.tcgcardgame.com/api/cards/sc", {
responseType: "json" responseType: "json"
})).data; })).data;
const allCards = allCardStrings.map(m => new Card(parseInt(m))); const allCards = allCardStrings.map(m => new Card(parseInt(m)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment