matheuss / google-translate-api

A free and unlimited API for Google Translate :dollar::no_entry_sign:
https://npmjs.com/package/google-translate-api
MIT License
2.91k stars 608 forks source link

Can we call this translate() in loop? #101

Open jayna456 opened 5 years ago

jayna456 commented 5 years ago

I have array of objects. From which I have one key value pair on which I want to translate it. By calling translate() in loop getting error of Response code 429 (Too Many Requests)

Below is my code:

for(let obj of notifyData) {
    translate(obj.body, {from: 'en', to: 'hr'})
              .then((response) => {
                console.log('tr...', response);
              })
              .catch((err) => {
                console.log('error in translation...',err);
              })
}

the function is not event taking first element from the array. i.e. array[0]. By doing this too, I am getting too many requests error..

Please help me out..