isData
Returns true/false whether the argument provided to the function should be loaded using an internal XHR request. Valid data can either be a string URL or a request Object: a “url” plus any fetch request options (such as “headers” or “method”). An Object with any other key, like a data row that happens to have a “url” field, is not loaded.
Basic example
Section titled “Basic example”Answers one question for a data config value: does it have to be fetched? A string is treated as a URL and an object with a url property (plus any fetch options such as headers) is a request; inline arrays and anything else are used as they are.
import {isData} from "@d3plus/data";
isData("/data/cities.json");
isData({
url: "https://api.example.com/rows",
headers: {Authorization: "Bearer …"},
});
isData([{id: 1}, {id: 2}]);
isData({data: [{id: 1}]});
isData(null);
isData(42);
Parameters
import {isData} from "@d3plus/data";
dataItemrequiredunknownThe value to be tested