i build a simple api that has a response body of
{ "name": "saud", "age": "22" }
it is hosted on http://localhost:7283/saud
using Node js express
app.get('/saud',(req,res)=>{res.status(200).send({name:'saud',age:'22'}) } );
it works if i access from a (physical mobile/Insomnia/Chrome) but when i host my Web app on localhost and the request is sent. i keep getting CircularProgressIndicator (meaning that there is no response in future)
this is my code for flutter:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SingleChildScrollView(
child: FutureBuilder<http.Response>(
future: getUrl(),
builder: (context, snapshot) {
if (snapshot.hasData) {
print(json.decode(snapshot.data!.body));
return Text(json.decode(snapshot.data!.body).toString());
}
return CircularProgressIndicator();
},
)),
);
}
Future<http.Response> getUrl() async {
return http.get(Uri.parse('http://192.168.92.226:7283/saud/'));
}
this exact same code is working perfectly for mobile app or insomnia