Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useGeoJSON(url, data, asFeatureCollection) {
const app = useApp(),
[geojson, setGeojson] = useState();
if (!(url.indexOf('/') === 0 || url.indexOf('http') === 0)) {
console.warn(new Error(`Use "{{rt}}/${url}" instead of relative URL`));
url = app.service + '/' + url;
}
useEffect(() => {
if (data) {
setGeojson(parseGeojson(data, asFeatureCollection));
return;
}
if (_cache[url]) {
setGeojson(parseGeojson(_cache[url], asFeatureCollection));
return;
}