Uncaught (in promise) TypeError: value.toLowerCase is not a function
See original GitHub issuenew autoComplete({
data: {
src: async query => {
let data
let url = new URL(
"/enhetsregisteret/api/enheter?",
"https://data.brreg.no/"
)
url.searchParams.append("navn", query)
url.searchParams.append("konkurs", "false")
url.searchParams.append("underAvvikling", "false")
url.searchParams.append(
"underTvangsavviklingEllerTvangsopplosning",
"false"
)
url.searchParams.append("size", 300)
await fetch(url, stdparams)
.then(json => (data = json))
return data._embedded.enheter
},
key: ["navn", "organisasjonsnummer"],
cache: false,
},
query: query => {
let nr = /^\d+$/.test(query.replace(/\s/g, ""))
if (nr === true) {
return query.replace(/\s/g, "")
}
return query
},
I modified autoComplete.js like this in io.js
const format = (value, diacritics) => {
console.log(typeof value + " : " + String(value))
console.log(value)
value = value.toLowerCase();
return (
diacritics
? value
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.normalize("NFC")
: value
).toString();
};
Here is the console log:
11:47:58.763 object : [object Object] io.js:65:10
11:47:58.763
Object { organisasjonsnummer: "991503234", navn: "HOGNIS MUSIC KJETIL ANDREAS HOGNESTAD", organisasjonsform: {…}, registreringsdatoEnhetsregisteret: "2007-07-17", registrertIMvaregisteret: false, naeringskode1: {…}, antallAnsatte: 0, forretningsadresse: {…}, institusjonellSektorkode: {…}, registrertIForetaksregisteret: false, … }
_links: Object { self: {…} }
antallAnsatte: 0
forretningsadresse: Object { land: "Norge", landkode: "NO", postnummer: "3124", … }
institusjonellSektorkode: Object { kode: "8200", beskrivelse: "Personlig næringsdrivende" }
konkurs: false
maalform: "Bokmål"
naeringskode1: Object { beskrivelse: "Utøvende kunstnere og underholdningsvirksomhet innen musikk", kode: "90.011" }
navn: "HOGNIS MUSIC KJETIL ANDREAS HOGNESTAD"
organisasjonsform: Object { kode: "ENK", beskrivelse: "Enkeltpersonforetak", _links: {…} }
organisasjonsnummer: "991503234"
registreringsdatoEnhetsregisteret: "2007-07-17"
registrertIForetaksregisteret: false
registrertIFrivillighetsregisteret: false
registrertIMvaregisteret: false
registrertIStiftelsesregisteret: false
underAvvikling: false
underTvangsavviklingEllerTvangsopplosning: false
<prototype>: Object { … }
io.js:66:10
11:47:58.765
Uncaught (in promise) TypeError: value.toLowerCase is not a function
format io.js:67
default searchController.js:15
find dataController.js:40
findMatches dataController.js:61
findMatches dataController.js:34
default index.f58c4ea9.js:22754
run eventController.js:27
timer io.js:93
setTimeout handler*debounce/< io.js:93
input eventController.js:41
addEvents eventController.js:71
eventsManager eventController.js:14
addEvents eventController.js:70
default index.f58c4ea9.js:22418
autoComplete autoComplete.js:37
init index.f58c4ea9.js:1214
stegNeste main.js:3093
startBeredskap main.js:3153
doInit main.js:3362
initPlakatDesigner main.js:3565
EventListener.handleEvent*["5lhNE"]< main.js:3608
newRequire index.f58c4ea9.js:71
<anonymous> index.f58c4ea9.js:120
<anonymous> index.f58c4ea9.js:143
io.js:67:16
default index.f58c4ea9.js:22758
AsyncFunctionNext self-hosted:692
(Async: async)
run eventController.js:27
timer io.js:93
(Async: setTimeout handler)
debounce io.js:93
input eventController.js:41
(Async: EventListener.handleEvent)
addEvents eventController.js:71
eventsManager eventController.js:14
addEvents eventController.js:70
default index.f58c4ea9.js:22418
autoComplete autoComplete.js:37
init index.f58c4ea9.js:1214
stegNeste main.js:3093
startBeredskap main.js:3153
(Async: EventHandlerNonNull)
doInit main.js:3362
AsyncFunctionNext self-hosted:692
(Async: async)
initPlakatDesigner main.js:3565
(Async: EventListener.handleEvent)
["5lhNE"]< main.js:3608
newRequire index.f58c4ea9.js:71
<anonymous> index.f58c4ea9.js:120
<anonymous> index.f58c4ea9.js:143
I think what format
is expecting is object.navn
, but what it’s getting is object
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
javascript - .toLowerCase not working, replacement function?
The .toLowerCase() function only exists on strings. You can call .toString() on anything in JavaScript to get a string representation.
Read more >TypeError: toLowerCase is not a function in JavaScript
The "toLowerCase is not a function" error occurs when we call the toLowerCase() method on a value that is not a string. To...
Read more >Uncaught TypeError: value.toLowerCase is not a function #54
This happens when converting a number to string: connection.select({ from: store, distinct: true, ignoreCase: true, where: {
Read more >tolowercase is not a function - Code Examples & Solutions For ...
TypeError : value.toLowerCase is not a function ; 1. var ans = 334; ; 2. var temp = ans.toString().toLowerCase(); ; 3. alert(temp); ;...
Read more >TypeError: error.toLowerCase is not a function
The "toLowerCase is not a function" error occurs when we call the toLowerCase() method on a value that is not a string.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got it!
data.key
has changed todata.keys
and this is basically the issue.My bad I should have made it more clear in the release notes
Try changing it and let me know how it goes 😃
The code in the issue description will use the public REST API. You can use that to get live data if you want.