Modern React Template - v0.0.10
    Preparing search index...

    Function createResource

    • Create a new resource

      Sends a POST request to create a new resource on the server.

      Type Parameters

      • TInput

        Type of the input data

      • TOutput

        Type of the response data

      Parameters

      • url: string

        API endpoint URL

      • data: TInput

        Data to send in the request body

      Returns Promise<TOutput>

      Promise resolving to the created resource

      const user = await createResource<UserInput, User>('/api/users', {
      name: 'John Doe',
      email: 'john@example.com'
      });