User class.

Since

2.0.0

Type Parameters

Hierarchy (view full)

Constructors

Properties

endpoint: string = 'posts'
_instance: WPJSSingleton

Methods

  • Set the userId.

    Parameters

    • userId: number

    Returns this

    Since

    2.0.0

    Example

    import {User} from "@quickdevelopment/wp-js";

    const user = new User();

    user.byUserId(1).fetch().then((user) => {
    console.log(user);
    })
  • Get a single user.

    Returns Promise<T | T[]>

    Since

    2.0.0

    Example

    import {User} from "@quickdevelopment/wp-js";

    const user = new User('users/1');

    user.fetch().then((user) => {
    console.log(user);
    })
  • Protected

    Fetch multiple objects from the endpoint.

    Returns Promise<T[]>

    Since

    2.0.0

  • Protected

    Get data about the current class.

    Type Parameters

    • T

    Returns Promise<T>

    Since

    1.0.0

  • Protected

    Get the search parameters.

    Returns URLSearchParams

  • Set search parameters for the request.

    Parameters

    • params: Record<string, string | number>

      Object containing search parameters.

    Returns this

    Since

    2.0.0

Generated using TypeDoc