keq-url
v2.0.4
Published
Set request url
Downloads
9,758
Maintainers
Readme
keq-url
Keq middleware for setting the request url.
Usage
setBaseUrl(baseUrl)
import { request } from "keq";
import { setBaseUrl, setHost } from "keq-url";
request.use(setBaseUrl("http://example.com/api"));
await request.get("/test");
// it will send request to 'http://example.com/api/test'
setOrigin(origin)
import { request } from "keq";
import { setOrigin } from "keq-url";
request.use(setOrigin("http://example.com:8080"));
await request.get("http://test.com/test");
// it will send request to 'http://example.com:8080/test'
setHost(host)
import { request } from "keq";
import { setHost } from "keq-url";
request.use(setHost("example.com"));
await request.get("http://test.com/test");
// it will send request to 'http://example.com/test'
Contributing & Development
If there is any doubt, it is very welcome to discuss the issue together.