Read the statement by Michael Teeuw here.
How to declare an array in config.js?
-
How does one declare an array in config.js within the config object? Just using [] does not work. For instance, declaring the following within a module’s config object:
biff: ['muffy','sport','spam']does NOT create an array. Instead, what is created is the comma separated string: “muffy,sport,spam”.
-
@fischershaw - Try double quotes. The
"character.biff: ["muffy","sport","spam"],Don’t forget the trailing comma.
-
@bhepler Yes, the trailing comma is present. The config.js file is syntactically correct, it just produces unexpected results. In this case a string instead of an array.
-
@fischershaw @bhepler the way you have done it works for me…
from my MyCovid19 module
in config.jsconfig:{ countries:["Italy","USA","China","Spain", "France",'Sweden'],in my code
for(var i in this.config.countries){ switch(this.config.countries[i].toLowerCase()) {oh, single or double quotes doesn’t matter, even in the same array, long as they are matched
why do you think it is a string? its an array of strings
-
open the developers window, (npm start dev or ctrl-shift-i on the keyboard),
-
select the sources tab,
-
look thru the items on the left, expand modules, find your module, click its .js file ,
-
then put a stop (click on the line edge to the left of the 1st statement after start),
-
then hit f5 (refresh page) and the page will be reloaded and the debugger will stop on that statement,
-
u can examine the variables in the config object
-
-
@sdetweil My dumb error which I corrected. Sorry to bother you.
-
@fischershaw is ok, we all learn… I just spent 2 hours trying to figure out why an api request failed, 404 not found
I had spelled apikey with an uppercase K…
which debugging approach did you use?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login