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`.
|
||||
*/
|
||||
type THandiworkOrder = "date" | "likes" | "relevance" | "replies" | "title" | "views";
|
||||
type TLatestResult = Result<GenericAxiosError | UnexpectedResponseContentType, string>;
|
||||
type TThreadResult = Result<GenericAxiosError, AxiosResponse<any>>;
|
||||
type TExecuteResult = Result<GenericAxiosError, AxiosResponse<any>>;
|
||||
|
||||
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 async execute(): Promise<TLatestResult | TThreadResult> {
|
||||
public async execute(): Promise<TExecuteResult> {
|
||||
// Local variables
|
||||
let response: TLatestResult | TThreadResult = null;
|
||||
let response: TExecuteResult = null;
|
||||
|
||||
// Check if the query is valid
|
||||
if (!this.validate()) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import validator from 'class-validator';
|
|||
import { urls } from "../../constants/url.js";
|
||||
import PrefixParser from '../prefix-parser.js';
|
||||
import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js";
|
||||
import { fetchHTML } from '../../network-helper.js';
|
||||
import { fetchGETResponse } from '../../network-helper.js';
|
||||
|
||||
// Type definitions
|
||||
export type TLatestOrder = "date" | "likes" | "views" | "title" | "rating";
|
||||
|
@ -74,7 +74,7 @@ export default class LatestSearchQuery implements IQuery {
|
|||
const decoded = decodeURIComponent(url.toString());
|
||||
|
||||
// Fetch the result
|
||||
return await fetchHTML(decoded);
|
||||
return await fetchGETResponse(decoded);
|
||||
}
|
||||
|
||||
public findNearestDate(d: Date): TDate {
|
||||
|
|
Loading…
Reference in New Issue