bitfocus / companion-module-generic-http

Generic HTTP module
MIT License
9 stars 19 forks source link

v1.1.1 with GET "Cannot read property 'trim' of undefined" #16

Closed cprima closed 2 years ago

cprima commented 2 years ago

Hi,

unfortunately I am getting errors in the Companion log:

Error executing action: Cannot read property 'trim' of undefined

I renamed my companion folder on my Raspberry Pi and did a fresh installation as per https://github.com/bitfocus/companion/wiki/Manual-Install-on-Raspberry-Pi

Tried several settings like empty baseurl, bogus header input and such, but could not get the module to execute.

Is it only my installation or can this be reproduced?

Maybe the GET action triggers line 152 (GET has no body)? if (action.options.body.trim() !== '') {

Here a minimal example:


        "qhXcokpuL": {
            "instance_type": "generic-http",
            "product": "HTTP Requests",
            "label": "http",
            "enabled": true,
            "prefix": "http://server.url/path/"
        }
    },
    "actions": {
        "1": [],
        "2": [{
                "id": "kJLp_CbXV",
                "label": "qhXcokpuL:get",
                "instance": "qhXcokpuL",
                "action": "get",
                "options": {
                    "url": "http://10.38.20.21:5000/usbgadget/command/userid",
                    "header": ""
                },
                "delay": 0
            }
        ],```

[sarmum_page 96_20211116-1308.companionconfig.txt](https://github.com/bitfocus/companion-module-generic-http/files/7546132/sarmum_page.96_20211116-1308.companionconfig.txt)
krocheck commented 2 years ago

@estilles

estilles commented 2 years ago

Checking ...

estilles commented 2 years ago

Yeah ... I'm missing a check to make sure body exists.

estilles commented 2 years ago

@krocheck / @cprima ... Thanks for reporting! PR submitted.

cprima commented 2 years ago

I can confirm that the issue is fixed (git pull'ed and yarn-update'd)

estilles commented 2 years ago

Thanks @cprima! Always appreciate your help.