mustafaabdujalil's avatar

Pagination

i want to get specific data from returned pagination data Example : i want to select name from product and name from pharmacy_product_size only i dont need any other data?? how can i do that


{
    "data": {
        "current_page": 2,
        "data": [
            {
                "id": 21,
                "pharmacy_id": 1,
                "product_id": 12,
                "is_approved": -1,
                "comment": null,
                "created_at": null,
                "updated_at": null,
                "product": {
                    "id": 12,
                    "name": "zaz",
                    "name_ar": "zaa",
                    "description": "zaaz",
                    "description_ar": "zazaza",
                    "category_id": 3,
                    "featured_img": "product-1537804598.png",
                    "status": null,
                    "brand_name": null,
                    "created_at": "2018-09-24 15:56:38",
                    "updated_at": "2018-09-24 15:56:38"
                },
                "pharmacy_product_size": {
                    "id": 16,
                    "pharmacy_product_id": 21,
                    "size_id": 1,
                    "price": 10,
                    "quantity": 12,
                    "sold": 0,
                    "available_stock": 12,
                    "low_stock": 5,
                    "out_stock": 0,
                    "status": 0,
                    "created_at": null,
                    "updated_at": null
                }
            }
        ],
        "first_page_url": "http://localhost:8000/api/pharmacy/1/category/3/products?page=1",
        "from": 2,
        "last_page": 20,
        "last_page_url": "http://localhost:8000/api/pharmacy/1/category/3/products?page=20",
        "next_page_url": "http://localhost:8000/api/pharmacy/1/category/3/products?page=3",
        "path": "http://localhost:8000/api/pharmacy/1/category/3/products",
        "per_page": 1,
        "prev_page_url": "http://localhost:8000/api/pharmacy/1/category/3/products?page=1",
        "to": 2,
        "total": 20
    },
    "status": "success"
}


0 likes
1 reply
lostdreamer_nl's avatar

Assuming this dataset is in a variable called result:

for(var index in result.data.data) {
    var row = result.data.data[index];
    console.log(row.product.name,  row.pharmacy_product_size .name);
}

Check your developers console (F12) and you'll see a log line with both names for each product.

Please or to participate in this conversation.