Git Product home page Git Product logo

fetch-api-demo's Introduction

fetch-api-demo

This is a web application in Vue demonstrates use of the Fetch API to talk to a REST server. There are two implementations of the REST server, one in Node.js (using Express) and one in Go (using gin). Both talk to a PostgreSQL database.

screenshot

To setup and start database server

Install the Postgres database server. On a Mac this can be done with brew install postgresql assuming homebrew is installed.

# Initialize the database.
sudo mkdir /usr/local/pgsql
sudo chown {your-user-name} /usr/local/pgsql
initdb -D /usr/local/pgsql/data

# Start the Postgres server.
pg_ctl -D /usr/local/pgsql/data start

# Create the "postgres" user.
create user postgres (enter "postgres" for the password)

To use Go server (instead of Node.js server)

cd go
go get github.com/gin-gonic/gin # REST server library
go get github.com/lib/pq # PostgreSQL driver
go run main.go

To use Node.js server (instead of Go server)

cd server
npm install # installs all dependencies
npm run dbsetup # recreates database tables, losing data
npm start # starts Express server

To build and run web client

cd to the top project directory.

npm install # installs all dependencies
npm run serve # starts local HTTP server

browse localhost:8080

fetch-api-demo's People

Contributors

mvolkmann avatar

Watchers

OSS Contributor avatar

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.