I am having an error while trying to make a get request on flutter
109
You have to return data corresponding to the return type of the function.
String url = 'http://localhost:9000/user/[email protected]';
Future<String> get makeRequest() async
{
var response = await http.get(Uri.encodeFull(url), headers: {"Accept": "application/json"});
print(response.body);
return(response.body);
}
Author by
Admin
Updated on December 19, 2022Comments
-
Admin over 1 year
String url = 'http://localhost:9000/user/[email protected]'; Future<String> get makeRequest() async { var response = await http .get(Uri.encodeFull(url), headers: {"Accept": "application"}); print(response.body); }
I get an error on makeRequests() that says "This function has a return type of 'Future', but doesn't end with a return statement."
-
pskink about 4 years
return response.body;
-
Ujas Patel about 4 yearschange var response to http.Response response.
-