NithishCodez / alexa-bot-api

A light weight [asynchronous / promise] based Neural Network [Artificial Intelligence]
6 stars 7 forks source link

Fix undefined return value #6

Closed ANF-Studios closed 3 months ago

ANF-Studios commented 3 years ago

This pull request addresses a fix for issue #5.

insomnia-creator commented 3 years ago

Update. This error keeps popping up,

FetchError: invalid json response body at https://alexa-bot-api-web-server.vercel.app/api/alexa?stimulus=what?lang=undefined reason: Unexpected token I in JSON at position 0
    at /home/pi/Desktop/lmfao/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Alexa.getReply (/home/pi/Desktop/lmfao/node_modules/alexa-bot-api/src/alexa.js:19:12)
    at async Client.<anonymous> (/home/pi/Desktop/lmfao/main.js:124:13) {
  type: 'invalid-json'

Why does this happen?

Because a) Sometimes while json-ifying it this is what response you get image

There is no fix for this unless @Major-Thrust fixes it himself.

ANF-Studios commented 3 years ago
res.name

will always return undefined as that is not a json property.

That's because the property is reply. That's what this pr changes.

ANF-Studios commented 3 years ago

Update. This error keeps popping up,

FetchError: invalid json response body at https://alexa-bot-api-web-server.vercel.app/api/alexa?stimulus=what?lang=undefined reason: Unexpected token I in JSON at position 0
    at /home/pi/Desktop/lmfao/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Alexa.getReply (/home/pi/Desktop/lmfao/node_modules/alexa-bot-api/src/alexa.js:19:12)
    at async Client.<anonymous> (/home/pi/Desktop/lmfao/main.js:124:13) {
  type: 'invalid-json'

There is no fix for this unless Major-Thrust fixes it himself.

But we can handle it. I'll add a catch block.

ANF-Studios commented 3 years ago

Also some rather useless changes but what are you getting by returning e? You need language too buddy.

@insomnia-creator, why though? It never returned that, what? Secondly, don't you think that's rather... pointless? Because, the client is providing the language, not the API or us.