wordpress_client 8.4.1 copy "wordpress_client: ^8.4.1" to clipboard
wordpress_client: ^8.4.1 copied to clipboard

A library to interact with the Wordpress REST API. Supports most of the common endpoints and all of the CRUD operations on the endpoints.

example/wordpress_client_example.dart

// ignore_for_file: avoid_print, unused_local_variable

import 'package:wordpress_client/wordpress_client.dart';

import 'auth_middleware.dart';

Future<void> main() async {
  final baseUrl = Uri.parse('https://example.com/wp-json/wp/v2');

  // Simple Usage
  final client = WordpressClient(
    baseUrl: baseUrl,
    bootstrapper: (bootstrapper) => bootstrapper
        .withDebugMode(true)
        .withMiddleware(AuthMiddleware())
        .withMiddleware(
          DelegatedMiddleware(
            onRequestDelegate: (request) async {
              return request.copyWith(
                headers: {
                  'X-My-Custom-Header': 'My Custom Value',
                },
              );
            },
            onResponseDelegate: (response) async {
              return response;
            },
          ),
        )
        .build(),
  );

  client.initialize();

  client.removeMiddleware(
    'LoggingMiddleware',
  );

  final response = await client.posts.list(
    ListPostRequest(
      perPage: 1,
      order: Order.asc,
    ),
  );

  response.map<void>(
    onSuccess: (response) {
      print('Posts Count: ${response.data.length}');
      // prints Posts Count: 1, as expected
    },
    onFailure: (response) {
      print(response.error);
    },
  );
}
29
likes
140
pub points
81%
popularity

Publisher

verified publisherarunprakashg.com

A library to interact with the Wordpress REST API. Supports most of the common endpoints and all of the CRUD operations on the endpoints.

Repository (GitHub)
View/report issues

Topics

#wordpress #fluent #crud #rest

Documentation

Documentation
API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (LICENSE)

Dependencies

collection, dio, http_parser, meta, path

More

Packages that depend on wordpress_client