groceries_api > backend (Express.js)
groceries_app > frontend (React Native)
- Start your wampserver
- import wireless_application_development.sql into database named wireless_application_development
2.1. you can setup your database configuration in groceries_api/config.js - In groceries_api folder, install all packages required by Express.js with
npm i
- In groceries_api folder, start api with
node index.js
- In groceries_app folder, install all packages required by React Native with
npm i
- In groceries_app folder, start React Native with
npx react-native run-android
This endpoint register new user.
POST http://localhost:3001/users/register
Parameter | Data Type | Description |
---|---|---|
name | String | - |
String | - | |
pasword | String | - |
phone | String | - |
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwiaWF0IjoxNjYwNjQ1NDg2LCJleHAiOjE2NjEyNTAyODZ9.GR_ZSfjEckFiVlON-cThiYBVID4q1fOYSyIWx8jyIMg"
This endpoint login user.
POST http://localhost:3001/users/login
Parameter | Data Type | Description |
---|---|---|
String | - | |
password | String | - |
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwiaWF0IjoxNjYwNjQ1NDg2LCJleHAiOjE2NjEyNTAyODZ9.GR_ZSfjEckFiVlON-cThiYBVID4q1fOYSyIWx8jyIMg"
This endpoint update user info.
POST http://localhost:3001/users/update
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
name | String | - |
password | String | - |
"User updated successfully"
This endpoint retrieve all products.
GET http://localhost:3001/products
Parameter | Data Type | Description |
---|---|---|
cat_id | String (optional) | - |
"{
"data": [
{
"id": 1,
"name": "Baking Ingredients A",
"img": "https://images.unsplash.com/photo-1590779033100-9f60a05a013d?w=500&q=80",
"desc": "This Baking Ingredients",
"SKU": "k5oZK0lcTcPPbZO",
"product_category_id": 1,
"price": 74,
"stock": 9
},
{
"id": 2,
"name": "Baking Ingredients B",
"img": "https://images.unsplash.com/photo-1590779033100-9f60a05a013d?w=500&q=80",
"desc": "This Baking Ingredients",
"SKU": "Sm7JXxhueMLgQy4",
"product_category_id": 1,
"price": 10,
"stock": 8
},
]
}"
This endpoint retrieve single products.
GET http://localhost:3001/products/:id
"
{
"id": 1,
"name": "Baking Ingredients A",
"img": "https://images.unsplash.com/photo-1590779033100-9f60a05a013d?w=500&q=80",
"desc": "This Baking Ingredients",
"SKU": "k5oZK0lcTcPPbZO",
"product_category_id": 1,
"price": 74,
"stock": 9
}
"
This endpoint retrieve all product categories.
GET http://localhost:3001/productcategories
"
{
"data": [
{
"id": 1,
"name": "Baking Ingredients",
},
{
"id": 2,
"name": "Biscuits & Cakes",
},
]
}
"
This endpoint retrieve user's cart items.
GET http://localhost:3001/carts
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
"
[
{
"id": 2,
"user_id": 5,
"product_id": 1,
"quantity": 4,
"name": "Baking Ingredients A",
"img": "https://images.unsplash.com/photo-1590779033100-9f60a05a013d?w=500&q=80",
"desc": "This Baking Ingredients",
"SKU": "k5oZK0lcTcPPbZO",
"product_category_id": 1,
"price": 74,
"stock": 9
},
{
"id": 4,
"user_id": 5,
"product_id": 14,
"quantity": 1,
"name": "Jam, Spreads & Honey B",
"img": "https://images.unsplash.com/photo-1590779033100-9f60a05a013d?w=500&q=80",
"desc": "This Jam, Spreads & Honey",
"SKU": "qd9nhRSpcvoXVrk",
"product_category_id": 7,
"price": 28,
"stock": 1
},
] "
This endpoint add item to user's cart.
POST http://localhost:3001/carts/add
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
product_id | Integer | - |
quantity | Integer | - |
"add product to cart successfully"
This endpoint edit item in user's cart.
POST http://localhost:3001/carts/edit
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
product_id | Integer | - |
quantity | Integer | - |
"update product quantity in cart successfully"
This endpoint delete item in user's cart.
POST http://localhost:3001/carts/delete
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
product_id | Integer | - |
"delete product in cart successfully"
This endpoint retrieve user's order.
GET http://localhost:3001/orders
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
"
wait still modifying
"
This endpoint add item to user's cart.
POST http://localhost:3001/orders/add
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
amount | Integer | - |
delivery_address | String | - |
payment_method | String | - |
products | Array [{product_id:1, quantity:1}] | - |
"create order successfully"
This endpoint address od an order (only address other too complex).
POST http://localhost:3001/orders/edit
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
delivery_address | String | - |
"update order successfully"
This endpoint delete item in user's cart.
POST http://localhost:3001/orders/delete
Key | Value | Description |
---|---|---|
Authorization | "Bearer token" | - |
Parameter | Data Type | Description |
---|---|---|
order_id | Integer | - |
"cancel order successfully"