easy_request 0.1.1 copy "easy_request: ^0.1.1" to clipboard
easy_request: ^0.1.1 copied to clipboard

A Dart package to easily make http requests.

Easy request makes easy to perform a HTTP request

Features #

GET, POST, PUT, DELETE requests

Getting started #

http package is used to make http requests

Usage #

import 'package:easy_request/easy_request.dart' show request;

void main() async {
  //GET
  final dynamic getData =
      await request(url: 'https://reqres.in/api/users?page=2');
  // print(getData);

  //POST => if a response is sent back to user, it will be available into the postData variable
  final dynamic postData = await request(
      url: 'https://reqres.in/api/users?page=2',
      method: 'POST',
      // headers: {'Content-Type': 'application/json'}, => NO NEED TO SET THIS HEADER
      body: {'name': 'Example post request', 'job': 'Post data to reqRes'});
  // print(postData);

  //PUT => The same as post
  final dynamic putData = await request(
      url: 'https://reqres.in/api/users?page=2',
      method: 'PUT',
      body: {
        'name': 'Modified data',
        'job': 'Job has been updated to PUT job'
      });
  // print(putData);

  //delete
  final deleteData = await request(
      url: 'https://reqres.in/api/users?page=2', method: 'DELETE');
  print('Delete: ${deleteData}');
}
1
likes
120
pub points
40%
popularity

Publisher

unverified uploader

A Dart package to easily make http requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

http

More

Packages that depend on easy_request