Comments (5)
Oh, this is on 8.0.7
wordpress_client: ^8.0.7
from wordpress_client.
Hey @menuology-chris
I attempted to replicate the scenario you described and obtained the expected results. I used the same domain as the one in the log file you provided.
I suspect that the issue stems from your codebase. Since you are calling setState
immediately after the network call, could you please verify your program flow? That might be causing the problem.
final baseUrl = Uri.parse('https://{ommited}.com/wp-json/wp/v2');
// Simple Usage
final client = WordpressClient(
baseUrl: baseUrl,
);
client.initialize();
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.toString());
},
);
from wordpress_client.
Thanks for the quick reply.
So interestingly, all I did was switch out the response code from the Dart style to the WP style as you referenced
final wpResponse = await client.posts.list(request);
switch (wpResponse) {
case WordpressSuccessResponse():
final data = wpResponse.data; // List<Post>
break;
case WordpressFailureResponse():
final error = wpResponse.error; // WordpressError
break;
}
to
response.map<void>(
onSuccess: (response) {
print('Posts Count: ${response.data.length}');
},
onFailure: (response) {
print(response.error.toString());
},
);
And now it works
void fetchArticles() async {
final baseUrl = Uri.parse('https://{mydomain}.com/wp-json/wp/v2');
final client = WordpressClient(
baseUrl: baseUrl,
);
client.initialize();
final response = await client.posts.list(
ListPostRequest(
perPage: 20,
order: Order.asc,
),
);
response.map<void>(
onSuccess: (response) {
print(response.data);
},
onFailure: (response) {
print(response.error.toString());
},
);
setState(() {});
}
Could there be something different with the Dart 3 style that would cause it to be missing the data?
from wordpress_client.
@menuology-chris I had tried both methods before sharing the previous update and it was working for me. I have also retried with the same sample and it was still working on both approaches. There are no differences between the two approach. Could you please check again?
from wordpress_client.
Closing this due to inactivity.
from wordpress_client.
Related Issues (20)
- why not one import? HOT 1
- first try crashed HOT 1
- Problem creating new users
- Login HOT 1
- client.media.create is not working HOT 3
- sorry, delete this issue. HOT 1
- Error when using tags.list() HOT 2
- Image Url extraction error HOT 3
- How can I update post's meta field? HOT 2
- Loading image from Wordpress on webapp Canvaskit failing HOT 2
- Deciding what fields are included in posts result HOT 12
- Parse "_embedded" variable to gain access to featuredmedia.source_url HOT 5
- Request Uri always return host in InternalRequester HOT 4
- Support for Linking and Embedding ? HOT 5
- Accept a list of status instead of single value in requests HOT 3
- Add models with everything nullable and methods for that and fields param to the request. HOT 3
- How to choose a different URL for each request? and how to mock differents responses based on url? HOT 2
- Should I capture the DioException? Or should the library map them? HOT 9
- Exception when getting posts with context as embed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordpress_client.