Hello Everyone... just working on my first FF/Dart project and I was wondering if I could get some guidance. I am trying to edit the response a get request using the API interceptor feature. the goal is only return specific information from the response body by using a regular expression.
@override
Future<ApiCallResponse> onResponse({
required ApiCallResponse response,
required Future<ApiCallResponse> Function() retryFn,
}) async {
// Perform any necessary calls or modifications to the [response] prior
// to returning it.
RegExp exp = RegExp(r'stock-code-text"><strong>(.*?)<\/strong>');
RegExp exp2 = RegExp(r'productPriceSpan money-3\">(.*?)<\/span>');
// String html = response; //.body.toString;
//response.statusCode
// Match match = regExp.firstMatch(response.body);
//String result = match.group(1);
Iterable<Match> pnmatches = exp.allMatches(response);
List stockCodes = [];
List pnPrice = [];
List out = [];
for (final Match m in pnmatches) {
stockCodes.add(m[1]);
//print(m.group(4));
//print(m[0]);
}
for (final Match m in price) {
pnPrice.add(m[1]);
//print(m.group(4));
//print(m[0]);
}
out = stockCodes + pnPrice;
return out;
}
}
apologies for the noobness and thanks in advance.