Giter Site home page Giter Site logo

Comments (5)

daniel-jones-deepl avatar daniel-jones-deepl commented on May 27, 2024 1

Hi @cittadhammo, thanks for creating this issue.

I was able to reproduce the error. I believe it is because the file main.js is executed in the browser. The deepl-node library is intended to be run by Node on the server, not in the browser. It might be possible with vite to execute functions on the server-side, but I am not familiar enough with vite to say how.

from deepl-node.

thibaultchazal avatar thibaultchazal commented on May 27, 2024

Exactly the same issue here with node v16.14.0

from deepl-node.

cittadhammo avatar cittadhammo commented on May 27, 2024

OK thank you.

I've used this code finally that works in the browser :

    const urlDeepL = 'https://api-free.deepl.com/v2/translate?auth_key='+authKey+'&text='+sentence+'&target_lang='+targetLanguage+'&preserve_formatting=1';
    const responseDeepL = await fetch(urlDeepL);
    const dataDeepL = await responseDeepL.json();
    const text = dataDeepL.translations[0].text

from deepl-node.

daniel-jones-deepl avatar daniel-jones-deepl commented on May 27, 2024

Hi @cittadhammo, great that you found a solution to your problem.

I want to warn you that with this approach your auth key is exposed in the browser: anyone accessing the page can see your key. So you should not share this page with anyone you do not trust, for example it should not be hosted on the internet.

from deepl-node.

DhammaCharts avatar DhammaCharts commented on May 27, 2024

Yes I was planning to request a key input from user before using the app on the internet.

Thanks for your help and be well ;-)

from deepl-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.