0

Anyone knows how base64 in JS works? How do i decode base64 in JS?

const base64 = require('base-64'); const str = 'Zm9vIMKpIGJhciDwnYyGIGJheg==' const decodeThisMsg = (msg) => { return base.64.decode(str); }; console.log(decodeMsg(str); I keep seeing "require is not defined"

22nd Jul 2019, 12:23 PM
Debee Origenius
Debee Origenius - avatar
5 ответов
+ 1
Your code is for node.js. For use in web browsers do: <script src="https://raw.githack.com/beatgammit/base64-js/master/base64js.min.js"></script>
22nd Jul 2019, 12:48 PM
Calviղ
Calviղ - avatar
22nd Jul 2019, 2:10 PM
Calviղ
Calviղ - avatar
+ 1
Node runs on web server, you need to install node on localhost or external server, upload the codes to the server or localhost. Browsers then can request the service from the web server.
23rd Jul 2019, 4:01 AM
Calviղ
Calviղ - avatar
0
So how do I go about solving it? I'm actually still new to JS
22nd Jul 2019, 12:54 PM
Debee Origenius
Debee Origenius - avatar
0
Thanks. If I actually want to use d node.js, how do I go about it?
22nd Jul 2019, 8:11 PM
Debee Origenius
Debee Origenius - avatar