customEndpoint static method
use this to reach a custom endpoint you've setup for a strapi collection
if you setup a endpoint name xEndPoint
for collection name xCollection
and the resulting route is
/xCollection/xEndPoint
, then you have to use this method like this
final response = await StrapiCollection.customEndpoint(
collection: "xCollection",
endPoint: "xEndPoint",
)
throws StrapiResponseException if response is failed
Implementation
static Future<List<Map<String, dynamic>>> customEndpoint({
required String collection,
required String endPoint,
Map<String, String>? params,
String? method,
int? limit,
}) async {
final path = collection + "/" + endPoint;
final response = await Strapi.i.request(
path,
params: params,
method: method,
);
if (response.failed) {
throw StrapiResponseException(
"failed to get from custom endpoint $path",
response,
);
}
if (!response.failed) {
StrapiObjectListener._inform(response.body);
}
return response.body;
}