Skip to main content

Posts

Showing posts with the label VueJS

How to call a .JSON file locally with VueJS

Sometimes we need to read our application basic settings but from an external file rather than having everything hardcoded so that some endpoints and settings can change through time even if you are in production mode, we can make a get method with Axios  to get information of a given .json file locally, in my case I called it data.json which is going to be at the same level of index.html, that .json file as you want to name it can change its values as you need through time, after we compiled the project the structure would be something like this and keep in mind, inside the folder dist is where are going to be the .js files, images,  and other needed files by the app. |-index.html |-data.json |--dist we must install Axios with   npm install --save axios,  I created a Vue empty project and a .json file called data.json {     "movies": [         { "title": "The Boy" , "watched": false },     ...

How to deploy a VueJS App using Nginx on Ubuntu

There are thousands of blogs and websites out there explaining how to do a hello world and how to start with VueJS, but in this little post, I’m just going to be explaining how to do deploy a VueJs app after you have run the command through the CLI npm run build . So when you run the command npm run build a dist folder is created and that folder’s got the essential .js files to run our app, when we want to run our app on an Nginx server by default the vue-router is not going to work well so that Nginx does not come ready to work by default with a VueJs app This is basically for a Linux Ubuntu distribution if you’ve got any other Linux distribution just pay attention where is going to be set the www/html folder and the Nginx settings so that this is useful for any Linux distribution  Install and configure nginx sudo apt install nginx Double check to make sure the nginx service is running with command service nginx status, then open your browser and enter ...