I am doing a flutter practice and I am making http requests, but I am having a problem and that is that when I make the request on the web it does it without problems but I run it on mobile and it tells me that the connection is refused.
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:bombishi_mobile/models/auth_model.dart';
class AuthService {
Future<void> login(AuthModel auth) async {
final response = await http.post(
Uri.parse('http://localhost:3000/api/v1/auth'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: jsonEncode({
'username': auth.username,
'password': auth.password,
}),
);
}
}