Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting undefined when using promises #105

Open
lffv opened this issue Jun 24, 2020 · 1 comment
Open

Getting undefined when using promises #105

lffv opened this issue Jun 24, 2020 · 1 comment

Comments

@lffv
Copy link

lffv commented Jun 24, 2020

Hi Guys, I am getting undefined when trying to use promises.
everything works well without promises, but when I change it to promises I am getting undefined from import.

Here is a sample code, any ideias?

var gpiop = require('rpi-gpio').promise;

gpiop.setup(38, gpiop.DIR_OUT)
    .then(() => {
        return gpiop.write(38, true)
    })
    .catch((err) => {
        console.log('Error: ', err.toString())
    })

The error is:

gpiop.setup(38, gpiop.DIR_OUT)
      ^

TypeError: Cannot read property 'setup' of undefined
    at Object.<anonymous> (/home/pi/Projects/RaspberryPiRelayControl/index.js:10:7)
@JamesBarwell
Copy link
Owner

That's really odd. Could you run these commands and give us the output, just to help sanity check?

node -v
npm ls

Maybe you could try running this as well to see what object is being imported, and why it seems to lack the promise interface:

var gpio = require('rpi-gpio');
console.log(gpio);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants