0

I am using the following code to translate something via a npm module called google-translate-api:

const translate = require('google-translate-api');

var sentence = "Bonjour, mon frere.";

translate(sentence, {from: 'fr', to: 'en' }).then(function(res) {
    console.log('Translation: '+res.text); 
    }).catch(err => {
        console.error(err);
    });   

This works on my Macbook. However, putting the same code onto the raspberry pi, I get a BAD REQUEST error from google - why that? I have tried to run the script logged in via ssh, via vnc and also logged in straight to the raspberry pi (not via any remote connection). It does still work perfectly on my machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.