I have a getJSON jquery function that uses data from an external file eg
$.getJSON( "data/dataset.json", function( data ) {
var mygeojson = {
type: "FeatureCollection",
features: [],
};
var waypoints = []
var all_points=[]
for (i = 0; i < data.length; i++) {
var lng = data[i].lng;
.....
I now have a local variable that contains the same data as the external data file.
eg
const dataset = [{..}, {..},......]
The data is in the exact same format.
How can I use a pure js function that references the dataset variable rather than the jquery getjson function?
Lets say you have a file with the following code as the data,
datasetFile.js
export const dataset = [{..}, {..},......];
and you have another file where you want to use this data
useDataset.js
import { dataset } from './datasetFile.js
console.log(dataset);
You should be good to go.