lnreader-plugins
lnreader-plugins copied to clipboard
[DEV] POST request doesn't work in cURL or node fetch mode
When making a POST request in cURL mode or Node Fetch, it is converted to a GET request.
Example:
- Create a 30min postbin url from https://www.postb.in
- then test the popular novel function in cURL mode
- refresh the postbin site
- the request is a GET instead of a POST, and of course there isn't the form data
import { fetchApi } from '@libs/fetch';
import { Plugin } from '@/types/plugin';
const POST_BIN_URL = 'https://www.postb.in/1761676424566-8950924063101';
class Test implements Plugin.PluginBase {
id = 'test'; name = 'Test'; site = ''; icon = ''; version = '0.0.0';
async popularNovels(): Promise<Plugin.NovelItem[]> {
const form = new URLSearchParams();
form.append('keyword', 'hello');
form.append('search', '1');
fetchApi(POST_BIN_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: form.toString(),
});
return [];
}
async parseNovel(): Promise<Plugin.SourceNovel> {
return {
path: '',
name: '',
cover: '',
chapters: [],
}
}
async parseChapter(): Promise<string> {
return '';
}
async searchNovels(): Promise<Plugin.NovelItem[]> {
return [];
}
}
export default new Test();