Git Product home page Git Product logo

adapp's Introduction

adApp

A simple advertisement CRUD application using Vuejs, Webpack , Node , Mongo and Expressjs

How to Run App

  1. clone the repository
  2. open a cmd line and cd inside adApp directory
  3. in the cmd line execute "npm install"
  4. execute "npm run app" to run the app
  5. open the app in your browser http://localhost:8080

adapp's People

Contributors

mal90 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

adapp's Issues

Help needed accessing express-backend from vuejs front-end

So this is a very simple application i started implementing to learn vuejs , node , express and webpack .
Code contains in this branch adApp vue (NOT in master!)

Current problem i have is aceessing an api end in express backend /api/products/
link to server.js file

.... //more code here 

MongoClient.connect(URL, (err, database) => {
  if (err) 
    return console.log(err);
  db = database;
  app.listen(3000, () => {
    console.log('listening on 3000');
  })
})

app.get('/api/products', (req, res) => {
    db.collection('products').find().toArray(function(err, results) {
    console.log(results)
    res.setHeader('Content-Type', 'application/json');
    res.send(JSON.stringify(results));
    })
})

I have used vue webpack-simple template and it uses 8080 port to run the application . However my server runs in 3000 port . I am trying access /api/products/ using a simple get method as follows
link to Product.vue file

export default {
  name: 'Products',
  methods: {
        get: function() {
            // GET request
            this.$http({
                url: '/api/products',
                method: 'GET'
            }).then(function(response) {
                console.log('ok');
            }, function(response) {
                console.log('failed');
            });
        }
    }
}

I get the 404 error like this

image

I understand this error . Since it tries to access the backend api end using localhost:8080 port therefore it throws a 404. How i can solve this issue ?

I've found few suggestion to use webpack dev server proxy . So i did as follows in the webpack.config.js

devServer: {
    historyApiFallback: true,
    noInfo: true,
     proxy: {
       "/api/*": "http://localhost:3000/api/"
     }
  },

But still i get the same result . If anyone can give me a solution or point me in the right direction is highly appreciated .

Help needed adding VueJS to this App.

Currently this adApp application uses AngularJS as the front-end technology . I want to migrate to VueJS . If anyone wants to contribute , holler at me :)

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.