Get All Products
fetch('https://apionlineshop.000webhostapp.com/api/')
.then(res=>res.json())
.then(json=>console.log(json))
{
title : "...",
slug : "...",
desctiprion : "...",
image : "...",
stock : "...",
discount : "...",
create_at : "...",
category : {..}
size : [{...}]
}
{
title : "...",
slug : "...",
desctiprion : "...",
image : "...",
stock : "...",
discount : "...",
create_at : "...",
category : {..}
size : [{...}]
}
Get a single product
fetch('https://apionlineshop.000webhostapp.com/api/hoodie-starcross')
.then(res=>res.json())
.then(json=>console.log(json))
{
title : "...",
slug : "...",
desctiprion : "...",
image : "...",
stock : "...",
discount : "...",
create_at : "...",
category : {..}
size : [{...}]
}
Get a product by search
fetch('https://apionlineshop.000webhostapp.com/api/products/search/hoodie starcross')
.then(res=>res.json())
.then(json=>console.log(json))
{
title : "...",
slug : "...",
desctiprion : "...",
image : "...",
stock : "...",
discount : "...",
create_at : "...",
category : {..}
size : [{...}]
}
Get a product by category
fetch('https://apionlineshop.000webhostapp.com/api/products/category/Hoodie')
.then(res=>res.json())
.then(json=>console.log(json))
{
title : "...",
slug : "...",
desctiprion : "...",
image : "...",
stock : "...",
discount : "...",
create_at : "...",
category : {..}
size : [{...}]
}
Add New Product
fetch('https://apionlineshop.000webhostapp.com/api/products', {
method : "POST",
body : JSON.stringify(
{
title: 'test product',
slug: 'test-product',
category: 'hoodie',
description: 'test product',
stock: 20,
price: '100000',
image: 'tesproduct.jpg',
size: [{...}]
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil tambah product",
}
Update Product
fetch('https://apionlineshop.000webhostapp.com/api/products/hoodie-starcross', {
method : "PUT",
body : JSON.stringify(
{
title: 'test product',
slug: 'test-product',
category: 'hoodie',
description: 'test product',
stock: 20,
price: '100000',
image: 'tesproduct.jpg',
size: [{...}]
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil Update product",
}
Delete Product
fetch('https://apionlineshop.000webhostapp.com/api/products/hoodie-starcross', {
method : "DELETE"
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil hapus product",
}
Get all categories
fetch('https://apionlineshop.000webhostapp.com/api/categories')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
title : "...",
slug : "...",
create_at : "...",
}
{
id : 30,
title : "...",
slug : "...",
create_at : "...",
}
Add category
fetch('https://apionlineshop.000webhostapp.com/api/categories')
method : "POST",
body : JSON.stringify(
{
title: 'test category',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil tambah category",
}
Update Category
fetch('https://apionlineshop.000webhostapp.com/api/categories/1', {
method : "PUT",
body : JSON.stringify(
{
title: 'update',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil Update category",
}
Get All carts
fetch('https://apionlineshop.000webhostapp.com/api/carts')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
size : "...",
total_price : "...",
quantity : "...",
created_at : "...",
product : {..}
user : {..}
}
{
id : 20,
size : "...",
total_price : "...",
quantity : "...",
created_at : "...",
product : {..}
user : {..}
}
Get a single cart
fetch('https://apionlineshop.000webhostapp.com/api/carts/1')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
size : "...",
total_price : "...",
quantity : "...",
created_at : "...",
product : {..}
user : {..}
}
Get cart by user
fetch('https://apionlineshop.000webhostapp.com/api/carts/user/user')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
size : "...",
total_price : "...",
quantity : "...",
created_at : "...",
product : {..}
user : {..}
}
Add New cart
fetch('https://apionlineshop.000webhostapp.com/api/carts', {
method : "POST",
body : JSON.stringify(
{
product_id: 1,
user_id: 1,
total_price: '100000',
quantity: 10,
size: "m",
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil tambah cart",
}
Update cart
fetch('https://apionlineshop.000webhostapp.com/api/carts/1', {
method : "PUT",
body : JSON.stringify(
{
product_id: 1,
user_id: 1,
total_price: '100000',
quantity: 10,
size: "m",
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil Update cart",
}
Delete carts
fetch('https://apionlineshop.000webhostapp.com/api/carts/1', {
method : "DELETE"
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil hapus carts",
}
Get All Orders
fetch('https://apionlineshop.000webhostapp.com/api/orders')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
no_order : "...",
total_pay : "...",
ongkir : "...",
payment : "...",
nohp : "...",
city : "...",
province : "...",
status : {..}
user : {..}
detail_order : [{...}]
}
{
id : 30,
no_order : "...",
total_pay : "...",
ongkir : "...",
payment : "...",
nohp : "...",
city : "...",
province : "...",
status : {..}
user : {..}
detail_order : [{...}]
}
Get orders by user
fetch('https://apionlineshop.000webhostapp.com/api/orders/user/1')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
no_order : "...",
total_pay : "...",
ongkir : "...",
payment : "...",
nohp : "...",
city : "...",
province : "...",
status : {..}
user : {..}
detail_order : [{...}]
}
Get orders by search
fetch('https://apionlineshop.000webhostapp.com/api/orders/search/{no_order}')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
no_order : "...",
total_pay : "...",
ongkir : "...",
payment : "...",
nohp : "...",
city : "...",
province : "...",
status : {..}
user : {..}
detail_order : [{...}]
}
Add Order
fetch('https://apionlineshop.000webhostapp.com/api/orders', {
method : "POST",
body : JSON.stringify(
{
user_id: 1,
status_id: 1,
cart_id: 1,
nohp: '..',
city: '..',
province: '..',
address: '..',
total: 1000,
ongkir: 20000,
payment: '..',
no_order: 09182,
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil tambah orderan",
}
Get All Sizes
fetch('https://apionlineshop.000webhostapp.com/api/size/dress')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
size : "...",
create_at : "...",
}
{
id : 10,
size : "...",
create_at : "...",
}
Add Size
fetch('https://apionlineshop.000webhostapp.com/api/size/dress', {
method : "POST",
body : JSON.stringify(
{
size: '..',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil tambah size",
}
Update Size
fetch('https://apionlineshop.000webhostapp.com/api/size/dress/{id}', {
method : "PUT",
body : JSON.stringify(
{
size: '..',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil update size",
}
Delete Size
fetch('https://apionlineshop.000webhostapp.com/api/size/dress/{id}', {
method : "DELETE"
})
.then(res=>res.json())
.then(json=>console.log(json))
{
status : 200,
message : "Berhasil delete size",
}
Get all status
fetch('https://apionlineshop.000webhostapp.com/api/status')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
name : "...",
create_at : "...",
}
{
id : 3,
name : "...",
create_at : "...",
}
Get all Users
fetch('https://apionlineshop.000webhostapp.com/api/users')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
name : "...",
email : "...",
profile : "...",
role_id : {..},
create_at : "...",
}
{
id : 1,
name : "...",
email : "...",
profile : "...",
role_id : {..},
create_at : "...",
}
Get a single User
fetch('https://apionlineshop.000webhostapp.com/api/user')
.then(res=>res.json())
.then(json=>console.log(json))
{
id : 1,
name : "...",
email : "...",
profile : "...",
role_id : {..},
create_at : "...",
}
Login
fetch('https://apionlineshop.000webhostapp.com/api/login', {
method : "POST",
body : JSON.stringify(
{
email: '..',
password: '..',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
message : 'hai user, welcome to home',
access_token : "eJncnhnhSr31ZMXARpP3hbhutavvf7Kqb8a2HpWU",
token_type : "Bearer",
}
Register
fetch('https://apionlineshop.000webhostapp.com/api/register', {
method : "POST",
body : JSON.stringify(
{
name: '..',
email: '..',
password: '..',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
data : {name : '..', email : '..', password : '..'}
access_token : "eJncnhnhSr31ZMXARpP3hbhutavvf7Kqb8a2HpWU",
token_type : "Bearer",
}
Logout
fetch('https://apionlineshop.000webhostapp.com/api/logout', {
method : "POST",
body : JSON.stringify(
{
token: '..',
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
{
message : "You have successfully logged out and the token was successfully deleted",
}