Irev-Dev/MRI-Volume-Slice

fetch data from search param in URL

Closed this issue · 1 comments

Add functionality so that if a URL to a data set on openneuro.org is put in the URL as a search parameter than the app fetches that data to display.

I.e.
mrislice.netlify.com/?https://openneuro.org/crn/datasets/ds001545/snapshots/1.0.0/files/sub-01:anat:sub-01_T1w.json
will display data from
https://openneuro.org/crn/datasets/ds001545/snapshots/1.0.0/files/sub-01:anat:sub-01_T1w.json

Instead of the hard coded dataset on line: 55 of 'script.js`

async function loadDefaultData() {
  const lastFile = await idb.get('LastNiftiFile');
  if (lastFile) return setupNifti(lastFile);
  const url = 'https://openneuro.org/crn/datasets/ds001417/files/sub-study002:ses-after:anat:sub-study002_ses-after_T1w.nii.gz';
  // load from the cache API or fetch if not found
let response;
 . . . 

hint: window.location.search will give you string following the ? in the url.

Hello, I can do this.