Skip to content

[DEV] POST request doesn't work in cURL or node fetch mode #1863

Open

Description

@error7404

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();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions