how to change it: — 1 Future<WpUser> authenticateViaTokenCustom(String? token) async {
_urlHeader[‘Authorization’] = ‘Bearer $token’;
final response = await http.post(Uri.parse(WpConfig.websiteUrl + ‘?rest_route=/’), headers: _urlHeader);
2:Future<WpUser> fetchMeUser(urlHeader) async {
final response = await http.get(Uri.parse(WpConfig.websiteUrl + ‘/wp-json/wp/v2/users/me’), headers: urlHeader);
3.`Future<List<Article>?> fetchPostsByCategoryId(int categoryId, int contentAmount) async {
final int _page = 1;
List<Article>? _articles;
var response = await http.get(Uri.parse(
“${WpConfig.websiteUrl}/wp-json/wp/v2/posts/?categories[]=$categoryId&page=$_page&per_page=$contentAmount&_fields=id,date,title,content,custom,link,tags”));`
4.Future fetchPostsByCategoryIdExceptPostId(int? postId, int? catId, int contentAmount) async {
var response = await http.get(Uri.parse(
“${WpConfig.websiteUrl}/wp-json/wp/v2/posts?exclude=$postId&categories[]=$catId&per_page=$contentAmount”));
5.Future fetchPopularPosts(int postLimit) async {
var response = await http.get(Uri.parse(“${WpConfig.websiteUrl}/wp-json/wordpress-popular-posts/v1/popular-posts?limit=$postLimit”));
6.Future fetchPostsBySearch(String searchText) async {
var response = await http.get(Uri.parse(“${WpConfig.websiteUrl}/wp-json/wp/v2/posts?search=$searchText”));
7.Future fetchCommentsById(int? id) async {
List<CommentModel> _comments = [];
var response = await http.get(Uri.parse(“${WpConfig.websiteUrl}/wp-json/wp/v2/comments?post=” + id.toString()));
8.
Future<bool> postComment(
int? id, String? name, String email, String comment) async {
try {
var response = await http.post(Uri.parse(“${WpConfig.websiteUrl}/wp-json/wp/v2/comments”),
9.`Future<bool> deleteCommentById (String? _urlHeader, int? id) async {
final StringBuffer url = new StringBuffer(WpConfig.websiteUrl + ‘/wp-json/wp/v2/comments’ + ‘/$id’);
HttpClient httpClient = new HttpClient();
HttpClientRequest request = await httpClient.deleteUrl(Uri.parse(url.toString()));
request.headers.set(HttpHeaders.contentTypeHeader, “application/json; charset=UTF-8”);`
9.Future<bool> updateCommentById (String? _urlHeader, int? id, String comment) async {
final StringBuffer url = new StringBuffer(WpConfig.websiteUrl + ‘/wp-json/wp/v2/comments’ + ‘/$id’);
HttpClient httpClient = new HttpClient();
HttpClientRequest request = await httpClient.postUrl(Uri.parse(url.toString()));