Skip to content

keq-request/keq-url

Repository files navigation

logo

KEQ-URL

version downloads license dependencies Codecov

Document | 中文文档

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.