Skip to content

Get a list of posts

hman25 edited this page May 9, 2022 · 2 revisions

Get a list of posts

Used to get a list of posts based on a certain location

URL : /api/posts/

Query Parameters : lat=[integer] where lat is the latitude for the location to get posts from, long=[integer] where long is the longitude for the location to get posts from, range=[integer] where range is the search radius (km) from location, numberOfPosts=[integer] where numberOfPosts is the number of posts to be retrieved (defaults to 10 if unspecified or less than 10)

Method : GET

Auth required : NO

Success Response

Code : 200 OK

Content example

[
    {
        "_id": "6270b67f8d4768ebf7d75893",
        "foodName": "Ollies Burgers & Ice Cream",
        "bodyText": "Ollies Burgers & Ice Cream",
        "tags": [
            "Ollies Burgers & Ice Cream",
            "Restaurant",
            "Food"
        ],
        "dietryRequirements": [],
        "restaurant": {
            "coordinates": {
                "lat": -36.9122379,
                "long": 174.7764292
            },
            "_id": "626374c488465216dbe5651f",
            "name": "Ollies Burgers & Ice Cream",
            "address": "802 Manukau Road, Royal Oak, Auckland 1061, New Zealand",
            "googlePlaceId": "ChIJqxoAV6ZIDW0Ra89JAnJRESQ",
            "googleMapsURL": "https://maps.google.com/?cid=2598948010076000107",
            "openHours": [
                "Monday: 11:00 AM – 10:00 PM",
                "Tuesday: 11:00 AM – 10:00 PM",
                "Wednesday: 11:00 AM – 10:00 PM",
                "Thursday: 11:00 AM – 10:00 PM",
                "Friday: 11:00 AM – 11:00 PM",
                "Saturday: 11:00 AM – 11:00 PM",
                "Sunday: 11:00 AM – 10:00 PM"
            ],
            "__v": 0
        },
        "numberOfLikes": 4,
        "rating": 0,
        "numberOfReviews": 0,
        "imageURLs": [
            "https://lh3.googleusercontent.com/places/AAcXr8owGp_spJ5Ifo0JUNPPhVaSDoe_RXvWe_kv9erIQZhwKiDlcsqH02leC_66iVvcf3vcdfT5lwWkEM-Z_XjxX0QrZdn-Kls6y30=s1600-w400"
        ],
        "__v": 0,
        "updatedAt": "2022-05-09T03:36:54.159Z"
    },
    {
        "_id": "6270b6808d4768ebf7d75898",
        "foodName": "Ollies Burgers & Ice Cream",
        "bodyText": "Ollies Burgers & Ice Cream",
        "tags": [
            "Ollies Burgers & Ice Cream",
            "Restaurant",
            "Food"
        ],
        "dietryRequirements": [],
        "restaurant": {
            "coordinates": {
                "lat": -36.9122379,
                "long": 174.7764292
            },
            "_id": "626374c488465216dbe5651f",
            "name": "Ollies Burgers & Ice Cream",
            "address": "802 Manukau Road, Royal Oak, Auckland 1061, New Zealand",
            "googlePlaceId": "ChIJqxoAV6ZIDW0Ra89JAnJRESQ",
            "googleMapsURL": "https://maps.google.com/?cid=2598948010076000107",
            "openHours": [
                "Monday: 11:00 AM – 10:00 PM",
                "Tuesday: 11:00 AM – 10:00 PM",
                "Wednesday: 11:00 AM – 10:00 PM",
                "Thursday: 11:00 AM – 10:00 PM",
                "Friday: 11:00 AM – 11:00 PM",
                "Saturday: 11:00 AM – 11:00 PM",
                "Sunday: 11:00 AM – 10:00 PM"
            ],
            "__v": 0
        },
        "numberOfLikes": 16,
        "rating": 0,
        "numberOfReviews": 0,
        "imageURLs": [
            "https://lh3.googleusercontent.com/places/AAcXr8qd5OFfNCJJl-ui49QyEJEe99BDQlb2QtCHVgWv7JRPMwVK65yVn3LdeZ2jdGKmD00IeycmRU_tP21Be2YcZYwbUnkevw2wU0U=s1600-w400"
        ],
        "__v": 0,
        "updatedAt": "2022-05-09T03:50:14.634Z"
    },
    . . . (And other posts returned)
]

Error Response

Condition : If something went wrong.

Code : 500 Internal Server Error

Content : {}

Navigation

Project Documentation

Frontend

Backend

Clone this wiki locally