import 'dart:convert';
import 'package:dio/dio.dart';
void main() async {
var test = [];
test = await start();
print(test);
}
start() {
List<int> ids = [1, 2, 3];
List answer = [];
ids.forEach((id) {
var url = 'https://jsonplaceholder.typicode.com/todos/$id';
var answer = query(url);
});
return answer;
}
query(url) async {
List ans = [];
var dio = Dio();
final response = await dio.get(url);
print(response.statusCode);
Map data = response.data;
data.entries.forEach((element) {
ans.add(element.key);
ans.add(element.value);
});
return ans;
}