forked from etsikt/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrreg.js
27 lines (25 loc) · 987 Bytes
/
brreg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//https://data.brreg.no/enhetsregisteret/api/docs/index.html#_eksempel_1_hent_enhet
//curl 'https://data.brreg.no/enhetsregisteret/api/enheter/123456789' -i
this.dashboard=this.dashboard||{};
this.dashboard.brreg = function() {
return {
_get : function(url, callback) {
var self = this;
$.ajax({
url: url,
success: function(data){
callback(data)
}, error: function(XMLHttpRequest, textStatus, errorThrown) {
let errMsg = 'Det oppstod en feil:' + errorThrown;
alert(errMsg);
console.log(errMsg);
}
});
},
getOrgFromNO_OrgNr : function(NOorgnr, callback) {
var orgnr = NOorgnr.substr(2);
let url = "https://data.brreg.no/enhetsregisteret/api/enheter/" + orgnr;
this._get(url, callback);
}
}
}();