-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.js
More file actions
29 lines (28 loc) · 666 Bytes
/
Copy pathapi.js
File metadata and controls
29 lines (28 loc) · 666 Bytes
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
import axios from "axios";
import Papa from "papaparse";
export default {
list: async () =>
axios
.get(
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQwdmDBtDZzhJ6r0gF307ZpTNWsAb6PDwUn5GGwwynVxsV82HQDL09MiZgvNWjzf9fkvKbYLgmCyO91/pub?output=csv",
{
responseType: "blob",
}
)
.then(
response =>
new Promise((resolve, reject) => {
Papa.parse(response.data, {
header: true,
complete: results =>
resolve(
results.data.map(product => ({
...product,
price: Number(product.price),
}))
),
error: err => reject(err.message),
});
})
),
};