Fetch GET response instead of HTML code

pull/73/head
MillenniumEarl 2021-03-04 10:14:21 +01:00
parent 5fb621d848
commit 3df82a36b8
2 changed files with 6 additions and 7 deletions

View File

@ -31,8 +31,7 @@ import ThreadSearchQuery, { TThreadOrder } from './thread-search-query.js';
* `views`: Order based on the number of visits. Replacement: `replies`. * `views`: Order based on the number of visits. Replacement: `replies`.
*/ */
type THandiworkOrder = "date" | "likes" | "relevance" | "replies" | "title" | "views"; type THandiworkOrder = "date" | "likes" | "relevance" | "replies" | "title" | "views";
type TLatestResult = Result<GenericAxiosError | UnexpectedResponseContentType, string>; type TExecuteResult = Result<GenericAxiosError, AxiosResponse<any>>;
type TThreadResult = Result<GenericAxiosError, AxiosResponse<any>>;
export default class HandiworkSearchQuery implements IQuery { export default class HandiworkSearchQuery implements IQuery {
@ -100,9 +99,9 @@ export default class HandiworkSearchQuery implements IQuery {
public validate(): boolean { return validator.validateSync(this).length === 0; } public validate(): boolean { return validator.validateSync(this).length === 0; }
public async execute(): Promise<TLatestResult | TThreadResult> { public async execute(): Promise<TExecuteResult> {
// Local variables // Local variables
let response: TLatestResult | TThreadResult = null; let response: TExecuteResult = null;
// Check if the query is valid // Check if the query is valid
if (!this.validate()) { if (!this.validate()) {

View File

@ -7,7 +7,7 @@ import validator from 'class-validator';
import { urls } from "../../constants/url.js"; import { urls } from "../../constants/url.js";
import PrefixParser from '../prefix-parser.js'; import PrefixParser from '../prefix-parser.js';
import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js";
import { fetchHTML } from '../../network-helper.js'; import { fetchGETResponse } from '../../network-helper.js';
// Type definitions // Type definitions
export type TLatestOrder = "date" | "likes" | "views" | "title" | "rating"; export type TLatestOrder = "date" | "likes" | "views" | "title" | "rating";
@ -74,7 +74,7 @@ export default class LatestSearchQuery implements IQuery {
const decoded = decodeURIComponent(url.toString()); const decoded = decodeURIComponent(url.toString());
// Fetch the result // Fetch the result
return await fetchHTML(decoded); return await fetchGETResponse(decoded);
} }
public findNearestDate(d: Date): TDate { public findNearestDate(d: Date): TDate {