How to choose a different URL for each request? and how to mock differents responses based on url?
It should also be possible to pass it as a parameter in each request to make mocks based on the URL possible if the client is shared as a dependency.
I have an app where the user enters the url and consults information about the site. You can also have multiple tabs open, so query multiple sites at same time with same client.
I pass the wordpress client as a dependency via provider or riverpod to each controller.
The idea is to be able to change the url in each request and also to be able to mock the response based on the url of the request for testing.
Thanks
Hi @MiniSuperDev I don't think it is a good idea to allow users to pass their own custom endpoints to pre-existing request classes. Afterall this is a library for the Wordpress REST API, it should integrate with the default wordpress rest api first and foremost.
If users want to use other endpoints, it's better to create another interface for the same and invoke the call from it.
If you have multiple tabs open, and you want to query multiple sites at the same time, i think it's better to keep different client for each tab. If not, you may need to handle the whole concurrency thing in the library itself, which i don't have the time to work on at the moment. Additionally, the library doesn't consume huge amount of memory, and it is disposable as well.
Furthermore, you could Create, Execute and Dispose the client easily by using the using(WordpressClient(...), (client) async { }); method.
@MiniSuperDev Hey, is there any update on this?