Skip to content

Instantly share code, notes, and snippets.

@ctalladen78
Created January 5, 2019 03:23
Show Gist options
  • Save ctalladen78/e3bf12bd8d38864388e53294bc6b1741 to your computer and use it in GitHub Desktop.
Save ctalladen78/e3bf12bd8d38864388e53294bc6b1741 to your computer and use it in GitHub Desktop.
dart / flutter http post request using typiform api
import 'dart:convert';
import 'dart:async';
import 'package:http/http.dart' as http;
// https://pub.dartlang.org/packages/http
Future<null> postData () async {
var client = new http.Client();
// signature : post( dynamic uri, body: dynamic ) returns Future<Response>
final response = await http.post('https://jsonplaceholder.typicode.com/posts/1',
body: {"test" : "new post"}
);
if(response.statusCode == 200){
print(response.body);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment