MCPcopy
hub / github.com/ChatGPTNextWeb/NextChat / fetch

Function fetch

app/store/access.ts:252–283  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250 );
251 },
252 fetch() {
253 if (fetchState > 0 || getClientConfig()?.buildMode === "export") return;
254 fetchState = 1;
255 fetch("/api/config", {
256 method: "post",
257 body: null,
258 headers: {
259 ...getHeaders(),
260 },
261 })
262 .then((res) => res.json())
263 .then((res) => {
264 const defaultModel = res.defaultModel ?? "";
265 if (defaultModel !== "") {
266 const [model, providerName] = getModelProvider(defaultModel);
267 DEFAULT_CONFIG.modelConfig.model = model;
268 DEFAULT_CONFIG.modelConfig.providerName = providerName as any;
269 }
270
271 return res;
272 })
273 .then((res: DangerConfig) => {
274 console.log("[Config] got config from server", res);
275 set(() => ({ ...res }));
276 })
277 .catch(() => {
278 console.error("[Config] failed to fetch config");
279 })
280 .finally(() => {
281 fetchState = 2;
282 });
283 },
284 }),
285 {
286 name: StoreKey.Access,

Callers 4

onRehydrateStorageFunction · 0.70
onRehydrateStorageFunction · 0.70
getVersionFunction · 0.70
stabilityRequestCallFunction · 0.70

Calls 5

getClientConfigFunction · 0.90
getHeadersFunction · 0.90
getModelProviderFunction · 0.90
errorMethod · 0.80
setFunction · 0.50

Tested by

no test coverage detected