Simple HTTP client that works both in Node.js and browser.
HTTP client X provides convenience methods for common HTTP requests. Each method returns a Promise which is rejected if HTTP status is an error (Status code is greater or equal to 400). The same result object is passed to both resolve and reject callbacks (Unless the request fails and no HTTP response data is available).
- get, head, delete: These methods take a single argument. Either a string representing the URL the request is send to or an object with properties url and optional headers
- post, put: These methods either takes two string arguments url and body or an object with properties url and optional body and headers
- request: This method either takes two string arguments method and url or an object with properties method, url, and optional body and headers
Behind the scenes, HTTP client X uses XMLHttpRequest in browsers and http/https modules in Node.js. Therefore testing software using HTTP client X can be done by faking those implementations or using http-client-x-mock which provides an unified API for mocking.
var http_client = ;http_client;
Clone the sources and install the package using
Run the following NPM script to lint, test and check coverage of the code:
npm run check
License and copyright
Copyright (c) 2016-2017 University Of Helsinki (The National Library Of Finland)
This project's source code is licensed under the terms of GNU Lesser General Public License Version 3 or any later version.