-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommons.js
33 lines (30 loc) · 867 Bytes
/
commons.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
const axios = require('axios');
const decodedJWT = async (token) => {
const response = await axios({
url: `${process.env.HOST_AUTH}/api/v1/auth/validate`,
method: 'POST',
timeout: 1000,
data: {
token: token
},
headers: {
"Content-Type": "application/json"
}
});
response.data.userId = response.data.userId
return response.data
}
const reviewProduct = async (productId) => {
const response = await axios({
url: `${process.env.HOST_REVIEWS}/api/v1/reviews/product/${productId}`,
method: 'GET',
timeout: 1000,
data: {},
headers: {
"Content-Type": "application/json"
}
});
return response.data;
}
exports.decodedJWT = decodedJWT;
exports.reviewProduct = reviewProduct;