🛒
محصولات
۱۰۰ محصول واقعی شامل گوشی، لپتاپ، لباس، کفش و لوازم خانگی
۱۰۰
تعداد کل
9
فیلد
ساختار داده
| فیلد | نوع | توضیح | الزامی |
|---|---|---|---|
title | string | عنوان | ✓ الزامی |
price | number | قیمت | ✓ الزامی |
description | string | توضیحات | ✓ الزامی |
category | string | دستهبندی | ✓ الزامی |
images | object | تصاویر | ✓ الزامی |
brand | string | برند | ✓ الزامی |
stock | number | موجودی | اختیاری |
discountPrice | number | قیمت با تخفیف | اختیاری |
rating | object | امتیاز | اختیاری |
Endpoints
روی هر endpoint کلیک کن تا تست کنی
مثال استفاده
// دریافت لیست محصولات
const res = await fetch('https://api.codeloop.ir/api/fake/products')
const { data } = await res.json()
console.log(data[0])
// { id: 1, title: "سامسونگ Galaxy S24 Ultra",, price: 490000, category: "برنامهنویسی", ... }
// فیلتر بر اساس دستهبندی
const res2 = await fetch('https://api.codeloop.ir/api/fake/products?category=برنامهنویسی')
// پیادهسازی با React و useEffect
function ProductList() {
const [products, setProducts] = React.useState([])
React.useEffect(() => {
fetch('https://api.codeloop.ir/api/fake/products')
.then(r => r.json())
.then(json => setProducts(json.data))
}, [])
return products.map(p => <div key={p.fid}>{p.title}</div>)
}دادههای واقعی
فیلتر: