forked from Mireia17/fetching-data-reply
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgooglefetch.js
More file actions
37 lines (25 loc) · 977 Bytes
/
googlefetch.js
File metadata and controls
37 lines (25 loc) · 977 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
30
31
32
33
34
35
// (GET) the data from GoogleSheetsAPI
const {google} = require('googleapis');
const keys = require('./keys.json');
async function gsrun(cl){
//console.log("Its calling,,.")
const gsapi = google.sheets({version:'v4', auth: cl}); //here we are connecting with google sheets
const opt = {
spreadsheetId:'14yYJ7AxzXhSviLwbMZkpqfqkFuTrhW3XxEbe7NJssKg',
range:'Content!A1:B13',
};
let data = await gsapi.spreadsheets.values.get(opt); //here instead of the get we could do plenty of other actions such as batch for example
return data;
// let dataArray = data.data.values;
// //console.log(data.data.values[1][1]);
};
exports.fetchGoogle = async () => {
const client = new google.auth.JWT(
keys.client_email,
null,
keys.private_key,
['https://www.googleapis.com/auth/spreadsheets']
);
const response = await gsrun(client);
return response.data.values;
};