-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample body.json
148 lines (136 loc) · 3.92 KB
/
Sample body.json
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
uber green 3FC060
Uber dark 162328
test jimmy coffee
{
"bizId": "U-a61zpbsDNVtKm9W1aqLw",
"bizName": "Jimmy's Coffee",
"imageUrl": "https://s3-media1.fl.yelpcdn.com/bphoto/kQm4vvHcZdlj7JKEKtWX7g/o.jpg",
"address1": "84 Gerrard Street W",
"address2",
"address3",
"city": "Toronto",
"country": "CA",
"state": "ON",
"phone": "+14167921141",
"latitude": 43.67428196976998,
"longitude": -79.39682006835938
}
"61aa8ec8646b96c676ad826e"
{
"bizId": "U-a61zpbsDNVtKm9W1aqLw",
"bizName": "Jimmy's Coffee",
"userId": "61ababad2ed65b378c146213",
"name": "Sarah Chan",
"address1": "84 Gerrard Street W",
"city": "Toronto",
"country": "CA",
"state": "ON",
"mediaLinkUrl": "https://youtu.be/0ELhQZUc7Lo?t=80",
"mediaEmbed": "",
"phone": "+14167921141",
"_id": "61abb2bad34aa958334ec70c",
}
{
"bizId": "U-a61zpbsDNVtKm9W1aqLw",
"bizName": "Jimmy's Coffee",
"userId": "61ababad2ed65b378c146213",
"name": "Sarah Chan",
"address1": "84 Gerrard Street W",
"city": "Toronto",
"country": "CA",
"state": "ON",
"mediaLinkUrl": "https://youtu.be/0ELhQZUc7Lo?t=80",
"mediaEmbed": "",
"phone": "+14167921141",
"_id": "61abb2bad34aa958334ec70c",
}
https://youtu.be/0ELhQZUc7Lo?t=180
{
"bizId": "Nq0UHjD_cKW9UbIJplQf_g",
"bizName": "Pow Wow Cafe",
"imageUrl": "https://s3-media2.fl.yelpcdn.com/bphoto/BPWxfIy4Y2Hu9v07n2YLHQ/o.jpg",
"address1": "213 Augusta Avenue",
"address2": "",
"address3": "",
"city": "Toronto",
"country": "CA",
"state": "ON",
"phone": "+14165517717",
"latitude": 43.65845826670497,
"longitude": -79.385555,
"userId": "61ababad2ed65b378c146213",
"name": "Sarah Chan",
"mediaLinkUrl": "https://youtu.be/0ELhQZUc7Lo?t=80",
"mediaEmbed": "",
}
token
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2MWFiYWJhZDJlZDY1YjM3OGMxNDYyMTMiLCJlbWFpbCI6InNhcmFoY2hhbkBnbWFpbC5jb20iLCJpYXQiOjE2Mzg2ODA2OTEsImV4cCI6MTYzODY4NDI5MX0.S_SF2riR_AnxsqBn_N3-Qz0bbSjwl7PyL_OQOGb9u4o
const influencerDBGetOwnInstances = async (req, res, next) => {
const influencerId = req..userId;
console.log(influencerId)
let ownInstances;
try {
ownInstances = await Instance.find({ userId:influencerId }).populate('instances');
} catch (err) {
const error = new HttpError(
'Fetching instances error.',
500
);
return next(error);
}
if (!ownInstances || ownInstances.instances.length === 0) {
return next(
new HttpError('Could not find places for the provided user id.', 404)
);
}
res.json({
places: ownInstances.instances.map(place =>
place.toObject({ getters: true })
)
});
}
const influencerDBGetOwnInstances = async (req, res, next) => {
const influencerId = req.params.userId;
console.log(userId)
let ownInstances;
try {
ownInstances = await Instance.find({ userId: influencerId }).populate('instances');
} catch (err) {
const error = new HttpError(
'Fetching instances error.',
500
);
return next(error);
}
if (!ownInstances || ownInstances.instances.length === 0) {
return next(
new HttpError('Could not find places for the provided user id.', 404)
);
}
res.json({
places: ownInstances.instances.map(place =>
place.toObject({ getters: true })
)
});
}
const influencerDBGetOwnInstances = async (req, res, next) => {
let userId = req.params.userId;
console.log(userId)
try {
let influencerProfile = await Influencer.findOne({ userId: userId});
if (!influencerProfile) {
const error = new HttpError(
'Could not find your profile.',
404
);
return next(error);
}
res.json({ influencerProfile: influencerProfile.toObject({ getters: true }) });
} catch (err) {
const error = new HttpError(
'Something went wrong, could not find the Influencer.',
500
);
return next(error);
}
}