I know how to do get and post request but im unsure on how to do delete request?
my json url and it's requirements:
String url = "http://35.186.145.243:8080/users";
{
"userId":"user1",
"price":"$1.300"
}
so i need to pass userId and price as parameters in order to delete the information from the api
main() async {
String url = "http://35.186.145.243:8080";
Map map = {
'user_id': "user1",
'price': "$1.300",
};
print(await apiRequest(url, map));
}
Future<String> apiRequest(String url, Map jsonMap) async {
HttpClient httpClient = new HttpClient();
httpClient.open('delete', url, 0, '/users');
httpClient.close();
return 'Success';
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("API DELETE"),
),
body:
Center(
child: RaisedButton(
color: Colors.lightBlueAccent,
child: Text("DELETE!"),
onPressed: () => main(),
),
),
);
}