MCPcopy Index your code
hub / github.com/plotly/dash / fetchCallback

Function fetchCallback

dash/dash-renderer/src/actions/callbacks.ts:490–530  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

488 }
489
490 const fetchCallback = () => {
491 const headers = getCSRFHeader(config) as any;
492 let url = `${urlBase(config)}_dash-update-component`;
493 let newBody = body;
494
495 const addArg = (name: string, value: string) => {
496 let delim = '?';
497 if (url.includes('?')) {
498 delim = '&';
499 }
500 url = `${url}${delim}${name}=${value}`;
501 };
502 if (cacheKey || job) {
503 if (cacheKey) addArg('cacheKey', cacheKey);
504 if (job) addArg('job', job);
505
506 // clear inputs as background callback doesnt need inputs, just verify for context
507 const tmpBody = JSON.parse(newBody);
508 for (let i = 0; i < tmpBody.inputs.length; i++) {
509 tmpBody.inputs[i]['value'] = null;
510 }
511 for (let i = 0; i < (tmpBody?.state || []).length; i++) {
512 tmpBody.state[i]['value'] = null;
513 }
514 newBody = JSON.stringify(tmpBody);
515 }
516
517 if (moreArgs) {
518 moreArgs.forEach(([key, value]) => addArg(key, value));
519 moreArgs = moreArgs.filter(([_, __, single]) => !single);
520 }
521
522 return fetch(
523 url,
524 mergeDeepRight(config.fetch, {
525 method: 'POST',
526 headers,
527 body: newBody
528 })
529 );
530 };
531
532 return new Promise((resolve, reject) => {
533 const handleOutput = (res: any) => {

Callers 1

handleFunction · 0.85

Calls 5

urlBaseFunction · 0.90
getCSRFHeaderFunction · 0.85
addArgFunction · 0.85
filterMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…