https://github.com/tecladocode/interacting-with-apis-javascript
A small repository to accompany our "How to interact with REST APIs from JavaScript" blog post
https://github.com/tecladocode/interacting-with-apis-javascript
Last synced: 4 months ago
JSON representation
A small repository to accompany our "How to interact with REST APIs from JavaScript" blog post
- Host: GitHub
- URL: https://github.com/tecladocode/interacting-with-apis-javascript
- Owner: tecladocode
- Created: 2019-09-25T13:29:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-06T19:47:09.000Z (about 5 years ago)
- Last Synced: 2023-08-03T05:43:15.766Z (almost 3 years ago)
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to interact with REST APIs from JavaScript
This repository accompanies our blog post "How to interact with REST APIs from JavaScript".
## How to run the Flask app
We've provided you with a sample REST API in the form of a Flask app.
To run it, you'll need Python 3 and Pipenv installed. Then, do:
```
cd backend
pipenv install
pipenv run flask run
```
## What does the app do?
The app stores movies. It has two endpoints, `POST /` and `GET /movies`.
### Adding movies
To add a new movie, send either form or JSON data containing `title` and `year` to the `POST /` endpoint.
See the examples `vanilla-post-form.html`, `vanilla-post-json.html`, and `fetch-post.html`.
### Retrieving movies
To get the movies currently stored, send a request to `GET /movies`.
See the examples `vanilla-get.html` and `fetch-get.html`.
## How to run the examples
Once the Flask app is running, just open the appropriate example file in your browser.
For example, on Windows, navigate to `file:///C:/Users/bob/vanilla-get.html` (or whatever path your file is in).