Skip to content

Commit 7e6d085

Browse files
authored
use stored API key when loading epivis 'shared' links (#107)
1 parent 7e57fb5 commit 7e6d085

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/api/EpiData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import DataSet, { DataGroup } from '../data/DataSet';
2323
import EpiDate from '../data/EpiDate';
2424
import EpiPoint from '../data/EpiPoint';
2525
import { get } from 'svelte/store';
26-
import { expandedDataGroups } from '../store';
26+
import { apiKey, expandedDataGroups, storeApiKeys } from '../store';
2727

2828
// import DataSet from "../data/DataSet";
2929
// import EpiDate from "../data/EpiDate";
@@ -260,6 +260,12 @@ export function importCOVIDcast({
260260
api_key: string;
261261
}): Promise<DataGroup | null> {
262262
const title = `[API] COVIDcast: ${data_source}:${signal} (${geo_type}:${geo_value})`;
263+
if (!api_key && get(storeApiKeys)) {
264+
// if no API key was passed to this method, but we have a saved one, use it...
265+
// this gets around access control and rate limiting when using an epivis "shared"
266+
// link (an URL-encoded signal list, processed through `deriveLinkDefaults`).
267+
api_key = get(apiKey);
268+
}
263269
return loadDataSet(
264270
title,
265271
'covidcast',

0 commit comments

Comments
 (0)