Coder Social home page Coder Social logo

ajax-notes-tombousquet's Introduction

Note-Taking App

Directions

In today's project, you will use Ajax to make GET, POST, PUT/PATCH, and DELETE requests, making a one-page application in the process.

Your application is a note-taking app. It should display a list of all your notes and give you the ability to create new notes, edit old notes, and delete notes. Notes are made up of a title, text, and the date/time most recently updated.

No wireframe is provided. You will have to create a design yourself. Looking at Google Keep may provide some inspiration.

Getting started

This application uses json-server to provide you with an API. To make sure it is installed, you will need to run the following commands:

npm install
cp sample-db.json db.json

To run json-server, run the following command:

npm start

This will start json-server and a web server. It should open a browser window at the same time. You will need to leave this running while you are working on this application.

The URL for your web application is http://localhost:8080.

The URL for your notes API is http://localhost:3000/notes/.

Using the notes API

To get a list of all notes, make a GET request to http://localhost:3000/notes/.

To add a new note, make a POST request to http://localhost:3000/notes/. You will need to send a body and headers. Your request will look like this:

fetch('http://localhost:3000/notes/', {
  method: 'POST', 
  headers: {"Content-Type": "application/json"}, 
  body: JSON.stringify({"title": "Hi", "body": "COOL"})
})
.then(r => r.json())
.then(
  // whatever you need to do next
)

The headers attribute lets json-server know you will be sending JSON to it for it to read. The body attribute is the JSON you are sending. If you have an object, then you must call JSON.stringify with that object.

To edit a note, make a PATCH request to http://localhost:3000/notes/:id where :id is the id of the note. This will also require the same headers and body as the above request.

To delete a note, make a DELETE request to http://localhost:3000/notes/:id.

Resources

The following resources will be very helpful for making this application:

ajax-notes-tombousquet's People

Contributors

tombousquet avatar amygori 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.