fix price and modular
This commit is contained in:
+3
-3
@@ -1,8 +1,8 @@
|
||||
import http from 'node:http';
|
||||
import https from 'node:https';
|
||||
import nodeFetch, { Headers as Headers$1, AbortController as AbortController$1 } from 'node-fetch-native';
|
||||
import { c as createFetch } from './shared/ofetch.03887fc3.mjs';
|
||||
export { F as FetchError, a as createFetchError } from './shared/ofetch.03887fc3.mjs';
|
||||
import nodeFetch, { AbortController as AbortController$1, Headers as Headers$1 } from 'node-fetch-native';
|
||||
import { c as createFetch } from './shared/ofetch.CWycOUEr.mjs';
|
||||
export { F as FetchError, a as createFetchError } from './shared/ofetch.CWycOUEr.mjs';
|
||||
import 'destr';
|
||||
import 'ufo';
|
||||
|
||||
|
||||
Generated
Vendored
+19
-3
@@ -67,6 +67,9 @@ function isJSONSerializable(value) {
|
||||
if (value.buffer) {
|
||||
return false;
|
||||
}
|
||||
if (value instanceof FormData || value instanceof URLSearchParams) {
|
||||
return false;
|
||||
}
|
||||
return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
|
||||
}
|
||||
const textTypes = /* @__PURE__ */ new Set([
|
||||
@@ -84,6 +87,9 @@ function detectResponseType(_contentType = "") {
|
||||
if (JSON_RE.test(contentType)) {
|
||||
return "json";
|
||||
}
|
||||
if (contentType === "text/event-stream") {
|
||||
return "stream";
|
||||
}
|
||||
if (textTypes.has(contentType) || contentType.startsWith("text/")) {
|
||||
return "text";
|
||||
}
|
||||
@@ -205,6 +211,12 @@ function createFetch(globalOptions = {}) {
|
||||
}
|
||||
if (context.options.onRequest) {
|
||||
await callHooks(context, context.options.onRequest);
|
||||
if (!(context.options.headers instanceof Headers)) {
|
||||
context.options.headers = new Headers(
|
||||
context.options.headers || {}
|
||||
/* compat */
|
||||
);
|
||||
}
|
||||
}
|
||||
if (typeof context.request === "string") {
|
||||
if (context.options.baseURL) {
|
||||
@@ -223,9 +235,13 @@ function createFetch(globalOptions = {}) {
|
||||
}
|
||||
if (context.options.body && isPayloadMethod(context.options.method)) {
|
||||
if (isJSONSerializable(context.options.body)) {
|
||||
context.options.body = typeof context.options.body === "string" ? context.options.body : JSON.stringify(context.options.body);
|
||||
context.options.headers = new Headers(context.options.headers || {});
|
||||
if (!context.options.headers.has("content-type")) {
|
||||
const contentType = context.options.headers.get("content-type");
|
||||
if (typeof context.options.body !== "string") {
|
||||
context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(
|
||||
context.options.body
|
||||
).toString() : JSON.stringify(context.options.body);
|
||||
}
|
||||
if (!contentType) {
|
||||
context.options.headers.set("content-type", "application/json");
|
||||
}
|
||||
if (!context.options.headers.has("accept")) {
|
||||
Reference in New Issue
Block a user