Code Monkey home page Code Monkey logo

fetch's Introduction

Fetchx

Fetchx is a simple, fast, and secure HTTP client for Dart. It leverages extensions to allow using url-like strings to make http requests.

Read in another language

Table of contents

Features

  • Get
  • Post
  • Put
  • Delete
  • Patch

Usage

To use this package add this to your pubspec.yaml

dependencies:
  fetchx: ^0.0.5

Then import the package

import 'package:fetchx/fetchx.dart';

Get

final response = await "https://jsonplaceholder.typicode.com/posts/1".get();

Post

final response = await "https://jsonplaceholder.typicode.com/posts".post({
  "title": "foo",
  "body": "bar",
  "userId": 1
});

Put

final response = await "https://jsonplaceholder.typicode.com/posts/1".put({
  "title": "foo",
  "body": "bar",
  "userId": 1
});

Delete

final response = await "https://jsonplaceholder.typicode.com/posts/1".delete();

Patch

final response = await "https://jsonplaceholder.typicode.com/posts/1".patch({
  "title": "foo"
});

EXPERIMENTAL

These features are still experimental and may change in the future. Any feedback is welcome to improve the package.

To Model Casting

class User extends BaseModel{
  final int? id;
  final String? name;
  User({
     this.id,
     this.name
  });

  @override
  User fromJson(Map<String, dynamic> json) => User(
        id: json["id"],
        name: json["name"]
      );
}

final response = await "https://jsonplaceholder.typicode.com/users/1".get().to<User>(()=>User());
print(response.name);

Cache

final response = await "https://jsonplaceholder.typicode.com/posts/1".get().cache();

Translations

This README is available in other languages:

fetch's People

Contributors

bryanbill avatar restyled-io[bot] avatar trekhub avatar xph0816 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fetch's Issues

Update the Documentations

The current documentation is shallow and only available in English. Expansion of the content and translation to several other languages will be convenient.

Exception Handler

Create a way to handle exceptions well especially for the .to() and .toList() type converters

Streamed Response

Currently, Fetchx only supports Future responses. It would be great to have Streamed Responses out of the box too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.