getToken function
GET request to the /tokens/:tokenId endpoint. Returns a specific token @param {int} tokenId - A token ID @returns {object} Response data with a specific token
Implementation
Future<Token> getToken(int tokenId) async {
final response = await get(baseApiUrl, TOKENS_URL + '/' + tokenId.toString());
if (response.statusCode == 200) {
final jsonResponse = await extractJSON(response);
final tokenResponse = Token.fromJson(json.decode(jsonResponse));
return tokenResponse;
} else {
throw ('Error: $response.statusCode');
}
}