Skip to content

Instantly share code, notes, and snippets.

@Abdullamhd
Last active September 30, 2019 10:23
Show Gist options
  • Select an option

  • Save Abdullamhd/49f62b0d4232696627526e8b7c2b740d to your computer and use it in GitHub Desktop.

Select an option

Save Abdullamhd/49f62b0d4232696627526e8b7c2b740d to your computer and use it in GitHub Desktop.
post json into server from dart
import 'package:http/http.dart' as http;
import 'dart:convert';
void main() async {
var url = 'http://localhost:3000/';
var body = jsonEncode({
'name' : 'Abood',
'Color' : 'blue'
});
var headers = {
'content-type': 'application/json'
};
var response = await http.post(url,headers : headers ,body:body );
print(response.statusCode);
print(response.body);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment