flutter – Cannot get any response from HTTP API – Stack Overflow
I searched tutorials and library documentations which I already followed the sample codes using either Dio or Http. However, I don’t know why I cannot get a response from calling the api. There is no error and any message allows me to debug. I read the logging from cloudwatch for the api gateway. There is no trigger. The app cannot be processed any more after calling the api as I use await for waiting for the response. How should I fix it?
Future makeGetRequest() async {
try {
const url="https://918pynqzta.execute-api.ap-southeast-1.amazonaws.com/dev/getAllElderly";
final uri = Uri.parse(url);
final response = await http.get(uri);
print(response);
} catch (e) {
print('Error: $e');
}
}
ElevatedButton(
onPressed: () async {
await makeGetRequest();
},)
Read more here: Source link
