Fetch GET response instead of HTML code
parent
5fb621d848
commit
3df82a36b8
|
@ -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()) {
|
||||||
|
@ -173,6 +172,6 @@ export default class HandiworkSearchQuery implements IQuery {
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue