Lấy danh sách thành phố, quận huyện
- /api/shipping/location: Lấy danh sách thành phố, quận huyện từ Nhanh.vn.
- The search param - (Data array)
Param | Text | Required | Description |
---|---|---|---|
type | string | No | CITY/DISTRICT/WARD (mặc định là CITY) |
parentId | int | No | Nếu type = DISTRICT thì parentId = id của thành phố cần lấy ra danh sách quận huyện.
Nếu type = WARD thì parentId = id của quận huyện cần lấy ra. |
- JSON decode the response to get the structure:
Key | Type | Description |
---|---|---|
code | int | 1 = success or 0 = failed |
messages | [ ] | is an array of error messages if code = 0 |
data | [ ] | Mảng danh sách thành phố hoặc quận huyện |
- Nếu type = CITY
[
{
"id": 2, // int
"name": "Hà Nội" // string
},
{
"id": 3,
"name": "Hồ Chí Minh"
}
// ...
]
- Nếu type = DISTRICT
[
{
"id": 2, // int
"parentId": 2, // int
"name": "Quận Hoàn Kiếm" // string
},
{
"id": 6,
"parentId": 2,
"name": "Quận Hai Bà Trưng"
}
// ...
]
- Nếu type = WARD
[
{
"id": 2, // int
"parentId": 3, // int
"name": "Phường Bạch Đằng" // string
},
{
"id": 6,
"parentId": 3,
"name": "Phường Bách Khoa"
}
// ...
]