June 2017
Intermediate to advanced
873 pages
18h 9m
English
One method of providing input to a REST API is via the calling URL, and this will be used to get a specified number of entries from the database using the following URL:
http://127.0.0.1:8080/api/quake/v1/recent/100
The implementation involves extending the pattern of the path with a curly bracket syntax (these correspond to the String parameters in the function):
@ApiMethod(path: 'recent/{count}')
Future<List<String>> recent(String count) async {
DaoQuakeAPI quakeAPI = new DaoQuakeAPI();
return await quakeAPI.fetchRecent(int.parse(count));
}The int.parse method is used to convert the count string into a database query parameter.
Read now
Unlock full access