MCPcopy
hub / github.com/NginxProxyManager/nginx-proxy-manager / post

Function post

frontend/src/api/backend/base.ts:102–130  ·  view source on GitHub ↗
({ url, params, data, noAuth }: PostArgs, abortController?: AbortController)

Source from the content-addressed store, hash-verified

100}
101
102export async function post({ url, params, data, noAuth }: PostArgs, abortController?: AbortController) {
103 const apiUrl = buildUrl({ url, params });
104 const method = "POST";
105
106 let headers: Record<string, string> = {};
107 if (!noAuth) {
108 headers = {
109 ...buildAuthHeader(),
110 };
111 }
112
113 let body: string | FormData | undefined;
114 // Check if the data is an instance of FormData
115 // If data is FormData, let the browser set the Content-Type header
116 if (data instanceof FormData) {
117 body = data;
118 } else {
119 // If data is JSON, set the Content-Type header to 'application/json'
120 headers = {
121 ...headers,
122 [contentTypeHeader]: "application/json",
123 };
124 body = buildBody(data);
125 }
126
127 const signal = abortController?.signal;
128 const response = await fetch(apiUrl, { method, headers, body, signal });
129 return processResponse(response);
130}
131
132interface PutArgs {
133 url: string;

Callers

nothing calls this directly

Calls 4

buildUrlFunction · 0.85
buildAuthHeaderFunction · 0.85
buildBodyFunction · 0.85
processResponseFunction · 0.85

Tested by

no test coverage detected