jsonstat/toolkit

TypeError: Cannot read property 'method' of null

oledybedokken opened this issue · 3 comments

const JSONstat = require("jsonstat-toolkit");

var url="https://data.ssb.no/api/v0/dataset/1054.json?lang=en";
JSONstat(url).then(main);
function main(j){
var ds=j.Dataset(0);
console.log(ds)
}

This returns error:
let method = init.method || input.method || 'GET';
^

let method = init.method || input.method || 'GET';
^

TypeError: Cannot read property 'method' of null
at new Request (/app/node_modules/node-fetch/lib/index.js:1217:21)
at /app/node_modules/node-fetch/lib/index.js:1439:19
at new Promise ()
at fetch (/app/node_modules/node-fetch/lib/index.js:1437:9)
at module.exports (/app/node_modules/jsonstat-toolkit/main.cjs:2:15410)
at Object. (/app/index.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)

Thanks for reporting this issue. I'm looking into it. In the meantime you can use:

const 
  url="https://data.ssb.no/api/v0/dataset/1054.json?lang=en",
  options={method: "GET"}  
;

JSONstat(url,options).then(...);

Downgrading to version 1.3.2 also fixed the issue. But thanks for your solution

It has been solved in 1.4.2 (just published).