MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / fetch

Function fetch

frontend/web/components/IntegrationList.tsx:407–472  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

405 }
406
407 const fetch = () => {
408 const integrationList = Utils.getIntegrationData()
409 setIsLoading(true)
410 Promise.all(
411 props.integrations.map((key) => {
412 const integration = integrationList[key]
413 if (integration) {
414 if (props.organisationId) {
415 return _data
416 .get(
417 `${Project.api}organisations/${organisationId}/integrations/${key}/`,
418 )
419 .catch(() => {})
420 } else if (integration.perEnvironment) {
421 return Promise.all(
422 ((ProjectStore.getEnvs() as any) || []).map((env: Environment) =>
423 _data
424 .get(
425 `${Project.api}environments/${env.api_key}/integrations/${key}/`,
426 )
427 .catch(() => {}),
428 ),
429 ).then((res) => {
430 let allItems: any[] = []
431 each(res, (envIntegrations, index) => {
432 if (envIntegrations && envIntegrations.length) {
433 allItems = allItems.concat(
434 envIntegrations.map((integration: any) => ({
435 ...integration,
436 flagsmithEnvironment: (
437 ProjectStore.getEnvs()?.[index] as Environment | null
438 )?.api_key,
439 })),
440 )
441 }
442 })
443 return allItems
444 })
445 }
446 if (key !== 'github') {
447 return _data
448 .get(
449 `${Project.api}projects/${props.projectId}/integrations/${key}/`,
450 )
451 .catch(() => {})
452 }
453 }
454 }),
455 ).then((res) => {
456 setActiveIntegrations(
457 map(res, (item) => (!!item && item.length ? item : [])),
458 )
459 setIsLoading(false)
460 })
461 const params = Utils.fromParam()
462 if (params && params.configure) {
463 const integrationList = Utils.getIntegrationData()
464

Callers 12

index.jsFile · 0.85
toChannelFunction · 0.85
_requestFunction · 0.85
GithubStarFunction · 0.85
TryIt.jsFile · 0.85
IntegrationListFunction · 0.85
addIntegrationFunction · 0.85
slackPostFunction · 0.85
uploadFileFunction · 0.85
runTeardownFunction · 0.85
globalSetupFunction · 0.85
fetchJSONFunction · 0.85

Calls 3

addIntegrationFunction · 0.85
allMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected