JavaScript

JavaScript is a high-level, prototype-based, dynamic scripting language used to create interactive web pages and applications.

JavaScript subscription active
You will receive email notifications for new publications on JavaScript.
162 Results
  • Question

    Getting error while installing Nodejs

    Following the sequence : $ cd ~ $ curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh $ sudo bash nodesource_setup.sh I am getting the error : Reading package lists... Done ...
    Accepted Answer: Hi @pranijman Please try using : bash sudo apt-get clean and then try again to instal NodeJS. If this doesn't work, what you can do is get rid of that repository, check your <^>/etc/apt/sources.list<^> file and any ...
    1 By pranijman Ubuntu Node.js JavaScript Ubuntu 20.04
  • Question

    How to make your Discord bot online 24/7.

    So I made a discord bot, and I'm trying to make it so it stays online all day, and all night. I installed pm2 but when I log off my computer the bot goes back offline. Is there any way to make the bot online 24/7 with...
    Accepted Answer: Hi there @edugutierrez2007, Yes indeed, you will have to use pm2 in order to configure your application so that it runs 24/7. Note that after installing pm2 you need to do some configuration in order to make it work. ...
    4 By edugutierrez2007 JavaScript Java Node.js
  • Question

    How to deploy a react native.js mobile app to web with Digital ocean software

    I have successfully created a mobile app with lot of APIs with react Native.js , and I will like to make the app available on the web too.. how do I deploy the mobile to the web with Digital ocean software?..thanks in...
    Accepted Answer: Hey there! You have a couple of options to host that on DigitalOcean. If your are looking for the most flexible option I would recommend using a Droplet to host that application. Droplets are VM's you can fully config...
    1 By setizens Deployment Development JavaScript React DigitalOcean App Platform
  • Question

    What does Javascript void(0); mean?

    Hi all, I wanted to create this question/answer about a topic that I've been recently asked a few times: What does Javascript void(0); mean?
    Accepted Answer: What is javascript:void(0)? If you have done any web development, you have most likely seen javascript:void(0) in some HTML files that you were working on. What javascript:void(0) is most commonly used for is to retur...
    1 By bobbyiliev JavaScript Getting Started Development
  • Question

    How to convert a string to an integer in JavaScript?

    Hi all, I wanted to create this question/answer on how to convert a string to an integer in JavaScript as this is something that I often get asked a lot about.
    Accepted Answer: Hi all, For everyone looking for a quick answer, here is how you could convert a string to an integer in Javascript with parseInt(): ``` var a = "20"; var b = parseInt(a); // Check the type of b: typeof b //Output 'nu...
    1 By bobbyiliev JavaScript Getting Started VS Code Programming Project
  • Question

    AppPlatform provides access to filesystem for NextJs with webservice for ISSG for caching?

    Hello, I would like to as if someone using AppPlatform web service for nextjs issg data fetching can confirm that AppPlatform give access to filesystem where next server is able to write generated pages and json files...
    Accepted Answer: 👋 @talenthem If you're hosting your NextJS application as a Web Service then you will have a filesystem that you can use ISSG against. I would like to highlight that this filesystem is ephemeral and is lost between d...
    1 By talenthem Node.js Deployment Development JavaScript DigitalOcean App Platform Next.js
  • Question

    Disabling cache of Service Worker in App platform (Static site)

    I am having problems with the service worker registration, most likely due to caching issues. Guidelines say that service-worker.js should not be cached. Is there a way to disable caching of some files like this in st...
    Accepted Answer: Hey there! Unfortunately there isn't currently a way to disable caching within static sites at this time. Having more control over caching may be an option that we will have in the future but isn't currently something...
    1 By webdever React DigitalOcean App Platform JavaScript
  • Question

    Which should I use jQuery vs VueJS

    I've recently started watching VueJS as everyone has been saying it's easier than jQuery( I watched some course on that as well). However I've been trying to build a testing application and hit some problems I couldn'...
    Accepted Answer: Hi @Remdore, As you most probably are aware, they do the same thing with some differences. With jQuery being available for more than 10 years around, it's certainly proved it's worth while VueJS is kinda new to the wo...
    1 By Remdore JavaScript
  • Question

    How to change the max filesize in media library

    I installed the strapi server on digital ocean and it works nice. But the standard configuration of the media library filesize is set to 1 MB, which is too less. How can i configure this to - let's say - 5MB per file ...
    Accepted Answer: The answer is not in the strapi configuration, but in the nginx.conf file. By default, Nginx has a limit of 1MB on file uploads. To set file upload size, you can use the clientmaxbodysize directive, which is part of ...
    2 By bstuijts JavaScript Node.js CMS
  • Question

    Express won't serve Client on Droplet

    Hello, I'm at my wits end so here we go. I created a working MERN stack app on DO a couple months ago (APP1), it works fantastically. I decided to use that app as a code base for another MERN app (APP2). Nearly nothin...
    Accepted Answer: Turns out it was a user permissions issue. Just had to run pm2 as "sudo pm2 start server.js" Thanks to all who were pondering.
    1 By Horse MongoDB Node.js React JavaScript
  • Question

    Is it possible to add a file to my app? Or is there another way to add a secret API key?

    I have my static content based app (DO App Platform) up and running. I'd like to add one file which contains an API key to the app. Is it possible to add the file without adding it to my github repo? Is there some wa...
    Accepted Answer: As far as adding a file, you could configure a custom build command to pull down a file during the build process. Outside of that we don't have any other mechanisms to add an "env" file. You can however, define a give...
    1 By raddevus API JavaScript HTML DigitalOcean App Platform
  • Question

    Javascript/CSS files don't load on website while hosting

    when I try running my server (with the domain being my ip address), It loads the base index.html but all of the files I reference (other CSS files, javascript files) in my directory aren't loaded. When I run on the Ch...
    Accepted Answer: HI @MoGb1, Is that your whole Nginx configuration? Additionally, can you try to add the following to the configuration file : location ~ \.css { add_header Content-Type text/css; } location ~ \.js { add_...
    1 By MoGb1 API Nginx JavaScript Initial Server Setup
  • Question

    How to Redirect to Another Website with JavaScript?

    Hello, What is the best way of redirecting a user to another website or page using pure JavaScript? Thank you!
    Accepted Answer: Hey there, One way to do that would be to use the location.href. Here's an example: javascript window.location.href = "<^>https://digitalocean.com<^>"; Here is a quick demo: Redirect user to another page using JavaSc...
    1 By bitmap JavaScript
  • Question

    dockerized and Kubernetes deployed puppeteer web scraper very slow

    I have built a puppeteer web scraper which takes a query, scrapes the result and saves it in a json. I want to create a process/pipeline to do this for >50k queries and save the results - ideally not having to wait 2 ...
    Accepted Answer: Using await before the sendRequest() function is a big no because when you use await the code will be forced to wait for the sendRequest() function to finishing executing. You mentioned that you have more than 50K que...
    1 By Dominikmaruszczak Node.js API Docker JavaScript Data Analysis Kubernetes
  • Question

    How to remove a property from an object in JavaScript?

    I recently got asked how to remove a property from an object in JavaScript. Here is an example object:: let linuxDistros = { "Ubuntu": "20.04", "CentOS": "8", "Debain": "10" }; Let's say that we wanted to remo...
    Accepted Answer: In order to remove a property from an object in JavaScript, you can use the delete followed by your Object and the property that you want to remove. If we take the object from the question: javascript let linuxDistro...
    2 By bobbyiliev JavaScript
  • Question

    Javascript Sort method

    I found this very informative post on the subject of the Javascript SORT method. I found, however, that VS Code does not recognize the method. This is the error message I got: numbers.sort((a,b) => a - b); ...
    Accepted Answer: That error looks like the type that you get when your numbers variable is not actually typed as an Array. For example, if you have some code where the numbers variable was an object or an integer or a string: javascri...
    1 By elemkey JavaScript
  • Question

    "Signature Does Not Match" when putting to presigned spaces upload url

    I am using the aws-sdk in Node.js to generate a presigned putObject upload url for use with DigitalOcean Spaces. The url gets generated just fine, however when I try putting to it using a REST client, I get a Signatur...
    Accepted Answer: So the reason this wasn't working is the content type MUST be specified when generating the presigned URL and specified once again by the client when it connects, and they must exactly match. Once I specified applicat...
    4 By sam0x17 DigitalOcean JavaScript Node.js
  • Question

    JavaScript causing issues

    Guys, I've been experiencing an issue where my function has been constantly executing without actually. Here is my JavaScript code ``` <script> //Constants const testInput = document.querySelector('[name=te...
    Accepted Answer: Hi @brendRos, The error is quite common and it's not actually an error, it's how JavaScript works. Turn your attention to your Event Listeners: //EventListeners testInput.addEventListener('click', ExecuteRelo...
    1 By brendRos JavaScript CoreOS
  • Question

    V2 create API POST call with Google Apps scripts

    I am trying to make a POST call work from within Google Apps scripts into the V2 create API. I have it working, but it doesn't execute the user_data formatted in either cloud-init or just as shell commands. Nothing sh...
    Accepted Answer: I discovered that you can use the Unicode encoding to put the LF in the json, and all it well now. For those wondering the code is : \u000A so "user_data" needed to look like this "user_data": "#!/bin/bash \u000A ...
    1 By FikesMedia DigitalOcean API and CLI (doctl) API JavaScript
  • Question

    Images not showing up with nodejs express on ubuntu server

    Problem: Images show up as broken icons. The images work perfectly fine when run locally on my own (windows 10) desktop, but on the ubuntu server it doe snot seem to work right. Things to Note: * File path is correct...
    Accepted Answer: Well now I feel silly. After hours of trying to narrow down the problem I finally found it! In case anyone else has a similar issue to me, this was how I fixed it. The whole problem was with the way I was with my FTP....
    1 By Decoded Development DigitalOcean JavaScript Node.js Programming Project Ubuntu 16.04