-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.js
161 lines (152 loc) · 5.84 KB
/
parse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Example
// bitresponse = [
// {
// "id": "1017460341",
// "url": "https://www.bandsintown.com/e/1017460341?app_id=234e5ea75754d065ee8978bfc59ead7d&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=event",
// "datetime": "2019-11-23T19:00:00",
// "description": "An absolute corker",
// "artist": {
// "id": "2265132",
// "name": "Crooked Colours",
// "url": "https://www.bandsintown.com/a/2265132?came_from=267&app_id=234e5ea75754d065ee8978bfc59ead7d",
// "mbid": "",
// "options": {
// "display_listen_unit": false
// },
// "image_url": "https://s3.amazonaws.com/bit-photos/large/8811694.jpeg",
// "thumb_url": "https://s3.amazonaws.com/bit-photos/thumb/8811694.jpeg",
// "facebook_page_url": "http://www.facebook.com/271800989531358",
// "tracker_count": 29210,
// "upcoming_event_count": 8
// },
// "venue": {
// "country": "Australia",
// "city": "Victoria Park",
// "latitude": "-21.15",
// "name": "Grapevine Estate",
// "region": "",
// "longitude": "149.2"
// },
// "lineup": [
// "Crooked Colours"
// ],
// "offers": [
// {
// "type": "Tickets",
// "url": "https://www.bandsintown.com/t/1017460341?app_id=234e5ea75754d065ee8978bfc59ead7d&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=ticket",
// "status": "available"
// }
// ],
// "artist_id": "2265132",
// "on_sale_datetime": ""
// },
// {
// "id": "1017460442",
// "url": "https://www.bandsintown.com/e/1017460442?app_id=234e5ea75754d065ee8978bfc59ead7d&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=event",
// "datetime": "2019-11-30T19:00:00",
// "description": "Full-bodied partying",
// "venue": {
// "country": "Australia",
// "city": "Pokolbin",
// "latitude": "-32.8",
// "name": "Roche Estate",
// "region": "",
// "longitude": "151.2833333"
// },
// "lineup": [
// "Crooked Colours"
// ],
// "offers": [
// {
// "type": "Tickets",
// "url": "https://www.bandsintown.com/t/1017460442?app_id=234e5ea75754d065ee8978bfc59ead7d&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=ticket",
// "status": "available"
// }
// ],
// "artist_id": "2265132",
// "on_sale_datetime": ""
// }
// ]
function parseBITData(artist) {
// let icons = ["airport", "aquarium", "cricket", "playground", "rocket", "horse-riding", "dog-park", "fire-station", "garden-centre", "dam", "theatre", "volleyball", "industry", "zoo", "waterfall", "heart", "globe", "scooter", "skiing", "music"]
let randomInt = Math.floor(Math.random() * 20)
return axios.get("https://rest.bandsintown.com/artists/" + artist + "/events?app_id=234e5ea75754d065ee8978bfc59ead7d&date=upcoming").then(function (axiosresponse) {
// response = axiosresponse
return axiosresponse.data.map(obj => ({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [parseFloat(obj.venue.longitude), parseFloat(obj.venue.latitude)]
},
"properties": {
"title": obj.venue.name,
"icon": "music",
"description": obj.offers[0].url,
"artist": obj.artist,// Ayan added more details for API call to render correct information to the HTML
"eventDate": obj.datetime,
"country": obj.venue.country,
"city": obj.venue.city,
"region": obj.venue.region
// add more details into description - as html
}
}))
})
// let objArray = []
// let obj = {
// "type": "Feature",
// "geometry": {
// "type": "Point",
// "coordinates": []
// },
// "properties": {
// "title": "",
// "icon": "monument",
// "description": ""
// }
// }
// for (r in response) {
// obj.geometry.coordinates.push(response[r].venue.latitude)
// obj.geometry.coordinates.push(response[r].venue.longitude)
// obj.properties.title = (response[r].venue.name)
// obj.properties.description = `<a href=${(response[r].offers[0].url)}>Get your Tickets Here!</a>`
// objArray.push(obj)
// obj = {
// "type": "Feature",
// "geometry": {
// "type": "Point",
// "coordinates": []
// },
// "properties": {
// "title": "",
// "icon": "monument",
// "description": ""
// }
// }
// }
// return objArray
// return response.map(obj => ({
// "type": "Feature",
// "geometry": {
// "type": "Point",
// "coordinates": [obj.venue.latitude, obj.venue.longitude]
// },
// "properties": {
// "title": obj.venue.name,
// "icon": "monument",
// "description": obj.offers[0].url
// }
// }))
}
//console.log(parseBITData('fosterthepeople'))
// return response.map(obj => ({
// "type": "Feature",
// "geometry": {
// "type": "Point",
// "coordinates": [obj.venue.latitude, obj.venue.longitude]
// },
// "properties": {
// "title": obj.venue.name,
// "icon": "monument",
// "description": obj.offers[0].url
// }
// }))