Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ReferenceError: string is not defined

I try to do iteration on object on nodejs using for in, on my local it’s working just fine. but when i deploy it to web service, it pass an error.

but when i tried on my local it work just fine

const queue = {
    mobilize : 'test',
    mobileTurnOn: 'mobileTurnOn',
    pushAdminNotif: 'pushAdminNotif',
    diffLocationAlert: 'diffLocationAlert'
  };
  for ( string in queue) {
    console.log(string, "key")
    console.log(queue[string], "value")
  };

it said variable is not defined

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ReferenceError: string is not defined
13
at /app/dist/app.js:59:10
12
at /app/node_modules/amqplib/callback_api.js:15:23
11
at /app/node_modules/amqplib/lib/connect.js:154:9
10
at succeed (/app/node_modules/amqplib/lib/connection.js:283:5)
9
at onOpenOk (/app/node_modules/amqplib/lib/connection.js:262:5)
8
at /app/node_modules/amqplib/lib/connection.js:165:32
7
at /app/node_modules/amqplib/lib/connection.js:159:12
6
at Socket.recv (/app/node_modules/amqplib/lib/connection.js:507:12)
5
at Object.onceWrapper (events.js:420:28)
4
at Socket.emit (events.js:314:20)
3
at Socket.EventEmitter.emit (domain.js:483:12)
2
at emitReadable_ (_stream_readable.js:557:12)
1
at processTicksAndRejections (internal/process/task_queues.js:83:21)

here is my terminal on my local running

>Solution :

You can try this:

for (const string in queue) {
  console.log(string, "key")
  console.log(queue[string], "value")
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading