Giter Club home page Giter Club logo

dart-wp's People

Contributors

allcontributors[bot] avatar ankiimation avatar danysz avatar nklage avatar okandemirofficial avatar provokateurin avatar theeomm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dart-wp's Issues

Flutter 2.0

I really love this package. Will this package ever be migrated to flutter null safety?

Problem with local server

Hello I have installed wordpress on local mamp server. So when i want to fetch post from local server i am getting below errors.

#0 packages/wordpress_api/src/main.dart 160:18 _discover
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ DioError [DioErrorType.response]: XMLHttpRequest error.
│ ⛔ dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28 get current
│ ⛔ packages/dio/src/dio_mixin.dart 819:20 assureDioError
│ ⛔ packages/dio/src/dio_mixin.dart 678:13 _dispatchRequest
│ ⛔ dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31
│ ⛔ dart-sdk/lib/async/zone.dart 1617:54 runBinary
│ ⛔ dart-sdk/lib/async/future_impl.dart 166:20 handleError
│ ⛔ dart-sdk/lib/async/future_impl.dart 716:46 handleError
│ ⛔ dart-sdk/lib/async/future_impl.dart 737:13 _propagateToListeners
│ ⛔ dart-sdk/lib/async/future_impl.dart 547:5 [_completeError]
│ ⛔ dart-sdk/lib/async/future_impl.dart 603:7 callback
│ ⛔ dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
│ ⛔ dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop

Documentation

Please provide a full documentation with fully working example to know how to use and fetch posts, pages, categories, tags, images, how to search in posts etc. 👍

How to use "embedModel"

Im Sorry for new Topic, but I need help. How can I get url from json below. I use argument const arg = {"per_page": "100", "_embed": "author"}; but I cannot get url. Please help. Thanks

"_embedded": { "author": [ { "id": 2, "name": "test", "url": "http://egmrm.ru", "description": "", ...

Exmaple App

We need example app for this library. I am new to programming and having problem with this package.

Here is code and I don't know data type so put List in return. How should I do if I don't want to put dynamic all over the app code and need a model?

 Future<List<dynamic>> fetchPosts(int pageNum) async {
    return wp.getPosts();
  }
}

Cast Error

Using this library with WordPress sites that have meta value in getPosts cause cast error. With the site which have empty meta, meta = [ ] (in JSON ) library is working properly. WordPress API send meta as a map,

"meta": {
            "spay_email": "",
            "jetpack_publicize_message": ""
        },

in this case library gives type error.

How to use the search function with this package?

Hello I'm trying to do a search function for my wordpress posts but I'm not quite sure on how to do with your package, can you refer me to an example made with your package and how it potentially works?

Always 404

I'm try do work with the sample:
import 'package:wordpress_api/wordpress_api.dart';

WordPressAPI api = WordPressAPI('https://jsonplaceholder.typicode.com/');

void main() async {
final wp = WordPressAPI('https://jsonplaceholder.typicode.com/posts');
final posts = await wp.getPosts();
for (final post in posts) {
print(post.title['rendered']);
}
}
But always return 404:
Exception: DioError [DioErrorType.RESPONSE]: Http status error [404]
#0 WordPressAPI.getAsyc (package:wordpress_api/src/main.dart:249:7)

#1 WordPressAPI.getPosts (package:wordpress_api/src/main.dart:281:23)
#2 main (package:mercurio_comunicator/getcardContent.dart:7:26)
#3 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Where to add Username and Password?

ToDo
Authentication using Application Passwords. WordPress 5.6+ only

I don't know what does that means. Where should I set my WordPress login info?

I run the app like example (within localhost WordPress) and I get this error:

│ #0   packages/wordpress_api/src/main.dart 160:20                          _discover
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ DioError [DioErrorType.response]: XMLHttpRequest error.

Can't get data from WP API if endpoint contains forward slash (/)

This code
final posts = (await wordpress.getAsync('posts'))['data'];
works fine.

But if you add a forward slash to the endpoint, flutter throws an exception:
Invalid argument(s): The source must not be null
Sample code: final posts = (await wordpress.getAsync('posts/1'))['data'];

How to get the typed data when make a request?

currently i am doing this

    final WPResponse response = await api.getPosts();
    final List<PostSchema> posts =
        (response.data as List).map((e) => PostSchema.fromJson(e)).toList();

is there a less boilerplate way and safe?

thank you

Example error

Hi,

When I try to run the example code, I got this error:

_TypeError (type 'String' is not a subtype of type 'Iterable')

Please resolve this.

Error in calling getPosts() method.

When i try to call wp.getPosts() method in my code, copy and pasted with necessary changes, I get the following:

[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
#0      _$PostSchemaFromJson 
package:wordpress_api/…/schemas/post.g.dart:32
#1      new PostSchema.fromJson 
package:wordpress_api/…/schemas/post.dart:131
#2      WordPressAPI.getPosts.<anonymous closure> 
[...]

EDIT: after trying to solve this problem, I temporary fixed this using the custom endpoint "method" to make it work, and it works. So as of now I can't tell if it's just a problem of mine or what. By the way, I'm still new to flutter, so it may be just a problem of mine...

Add more abstraction

Thanks for the package! I believe you should add more extraction, like a function called getPosts() for fetching posts instead of leaving it up to the dev to read the wp api first. This is how other api clients are written, and it'll also prevent more errors from misspelled endpoints.

add "_embedded" field

this field available when add arg "_embed=true" and contains these objects: category, thumbnail, author,...

No get method found.

Hey, guys.

in your sample code.
Retrieve data from a custom endpoint.

My code makes error.
The method 'get' isn't defined for the type 'WordPressAPI'.
Try correcting the name to the name of an existing method, or defining a method named 'get'.

  void main() async {
    final api = WordPressAPI('wp-site.com');
    final WPResponse res = await api.get(endpoint: 'your-custom-endpoint');
    print(res.data);
  }

Update User Model

The user model has a List of roles as property, but WP-API never has roles in the response, I had to manually set the roles attribute to an empty List so I could retrieve the List of Users
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.