Я знаю, как получить и отправить запрос, но я не уверен, как сделать запрос на удаление?
мой URL-адрес JSON и его требования:
String url = "http://35.186.145.243:8080/users";
{
"userId":"user1",
"price":"$1.300"
}
, поэтому мне нужно передать userId и цену в качестве параметров, чтобы удалить информацию из 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(),
),
),
);
}