@aurelle/http-fetcher
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -53,2 +53,9 @@ import { HttpFetcherError } from "src/lib/http-fetcher-error"; | ||
} | ||
export declare enum HttpMethod { | ||
GET = "GET", | ||
POST = "POST", | ||
PUT = "PUT", | ||
PATCH = "PATCH", | ||
DELETE = "DELETE" | ||
} | ||
export interface HttpFetcherRequest<RequestBodyType = any> { | ||
@@ -55,0 +62,0 @@ params: HttpFetcherQueryParams; |
@@ -37,3 +37,4 @@ var __defProp = Object.defineProperty; | ||
HttpFetcher: () => HttpFetcher, | ||
HttpFetcherError: () => HttpFetcherError | ||
HttpFetcherError: () => HttpFetcherError, | ||
HttpMethod: () => HttpMethod | ||
}); | ||
@@ -157,3 +158,5 @@ module.exports = __toCommonJS(src_exports); | ||
async get(url, { headers = {}, params = {} } = {}) { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "GET" | ||
}); | ||
const request = { | ||
@@ -168,3 +171,5 @@ fetchRequest, | ||
async post(url, body, { headers = {}, params = {} } = {}) { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "POST" | ||
}); | ||
const request = { | ||
@@ -180,3 +185,5 @@ fetchRequest, | ||
async put(url, body, { headers = {}, params = {} } = {}) { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "PUT" | ||
}); | ||
const request = { | ||
@@ -192,3 +199,5 @@ fetchRequest, | ||
async delete(url, { headers = {}, params = {} } = {}) { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "DELETE" | ||
}); | ||
const request = { | ||
@@ -203,6 +212,17 @@ fetchRequest, | ||
}; | ||
// src/http-fetcher.types.ts | ||
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => { | ||
HttpMethod2["GET"] = "GET"; | ||
HttpMethod2["POST"] = "POST"; | ||
HttpMethod2["PUT"] = "PUT"; | ||
HttpMethod2["PATCH"] = "PATCH"; | ||
HttpMethod2["DELETE"] = "DELETE"; | ||
return HttpMethod2; | ||
})(HttpMethod || {}); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
HttpFetcher, | ||
HttpFetcherError | ||
HttpFetcherError, | ||
HttpMethod | ||
}); |
{ | ||
"name": "@aurelle/http-fetcher", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A blazing fast, lightweight and easy to use HTTP client based on the fetch API.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -155,3 +155,6 @@ import { JSON_HEADERS } from "src/constants"; | ||
): Promise<HttpFetcherResponse<ResponseType>> { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "GET", | ||
}); | ||
const request: HttpFetcherRequest = { | ||
@@ -172,3 +175,5 @@ fetchRequest: fetchRequest, | ||
): Promise<HttpFetcherResponse<ResponseType>> { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "POST", | ||
}); | ||
const request: HttpFetcherRequest = { | ||
@@ -190,3 +195,5 @@ fetchRequest: fetchRequest, | ||
): Promise<HttpFetcherResponse<ResponseType>> { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "PUT", | ||
}); | ||
const request: HttpFetcherRequest = { | ||
@@ -207,3 +214,5 @@ fetchRequest: fetchRequest, | ||
): Promise<HttpFetcherResponse<ResponseType>> { | ||
const fetchRequest = new Request(this.makeUrl(url, params)); | ||
const fetchRequest = new Request(this.makeUrl(url, params), { | ||
method: "DELETE", | ||
}); | ||
const request: HttpFetcherRequest = { | ||
@@ -210,0 +219,0 @@ fetchRequest: fetchRequest, |
@@ -59,2 +59,10 @@ import { HttpFetcherError } from "src/lib/http-fetcher-error"; | ||
export enum HttpMethod { | ||
GET = "GET", | ||
POST = "POST", | ||
PUT = "PUT", | ||
PATCH = "PATCH", | ||
DELETE = "DELETE", | ||
} | ||
export interface HttpFetcherRequest<RequestBodyType = any> { | ||
@@ -61,0 +69,0 @@ params: HttpFetcherQueryParams; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48358
712