1.0.1 • Published 6 years ago

miniquest v1.0.1

Weekly downloads
8
License
-
Repository
-
Last release
6 years ago

MiniQuest

Lightweight XHR wrapper.

Installation

  npm i miniquest --save

Usage

GET

  miniquest.get("/path")
  .then((body) => {
    console.log(body);
  })
  .catch(() => {
    console.log("Network error!");
  });

GET JSON output

  miniquest.get("/path", {
    parseJson: true
  })
  .then((body) => {
    console.log(body);
  })
  .catch(() => {
    console.log("Network error!");
  });

POST form data

  miniquest.post("/path", new FormData(document.querySelector("form")))
  .then((body) => {
    console.log(body);
  })
  .catch(() => {
    console.log("Network error!");
  });

POST urlencoded string

  miniquest.post("/path", "foo=bar")
  .then((body) => {
    console.log(body);
  })
  .catch(() => {
    console.log("Network error!");
  });