私は本当に簡単な作業であると確信しています。私はGoogleスプレッドシートからデータを抽出するためにGoogleスプレッドシートAPIを使用しています。私は、Javascriptオブジェクトにデータを格納したい。JavascriptオブジェクトとしてGoogle APIリクエストを保存する
これまでのところ、APIからデータを正常に要求できましたが、コンソールに出力できるため、正常に動作しています。しかし、私はこのデータをオブジェクトとして保存しようとしていませんでした。
https://developers.google.com/api-client-library/javascript/start/start-jsとhttps://developers.google.com/sheets/api/samples/readingからコードテンプレートを取得しました。
これは、現在、私のコードです:
<script src="https://apis.google.com/js/api.js"></script>
<script>
function start() {
// 2. Initialize the JavaScript client library.
gapi.client.init({
'apiKey': 'key',
// clientId and scope are optional if auth is not required.
'clientId': 'client_id',
'scope': 'profile'}).then(function() {
// 3. Make the request
return gapi.client.request({
'path': 'https://sheets.googleapis.com/v4/spreadsheets/sheet_id/values/Sheet3'});
}).then(function(response){
console.log(response.result);
});
};
// 1. Load the JavaScript client library.
gapi.load('client', start);
</script>
をしかし、私はこのデータを保存し、後でそれにアクセスする方法を見当もつかない。私は助けていただければ幸いです!
あなたは、コールバック関数と事前に定義されたグローバル変数が必要になります。 –