Software which fetch e-commerce like data and perform logic on it.
JavaScript
Node.js
Table below presents functions which are responsible for data fetching from REST API.
Resources
is only name convention here to generalize usage of an API endpoints.
You can click specific endpoint in order to get more in-depth information about usage.
Additionally you can click function in order to check implementation.
Method | Endpoints | Function |
---|---|---|
GET |
/resources |
getAll |
GET |
/resources/:id |
getOne |
Table below shows util functions which perform logic on data fetched from an API.
Function |
---|
Aggregate prices by category |
Highest cart value |
Furthest distance between users |
Clone repository.
git clone https://github.com/wojciechszmelczerczyk/js-ecommerce-data-fetch.git
Navigate to project root directory.
cd ./js-ecommerce-data-fetch
Install dependencies.
npm i
Create following .env
file in project root directory.
BASE_URL=https://fakestoreapi.com
CARTS_URL=carts
PRODUCTS_URL=products
USERS_URL=users
CARTS_DATE_QUERY_STR=?startdate=2000-01-01&enddate=2023-04-07
Project use CommonJS
syntax, so export is not supported.
Please change node_modules/geolocation-distance-between/lib/index.js line 54 from export
to module.exports =
.
Run server.
npm run start
Table below represents docs for unit tests.
Unit tests |
---|
getAll |
getOne |
Run tests.
npm run test