@@ -27,15 +27,11 @@ const client = new Grid({
2727 apiKey: " YOUR_API_KEY" ,
2828});
2929
30- async function main () {
31- const response = await client .workbooks .query (' YOUR_WORKBOOK_ID' , {
32- read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ],
33- });
34-
35- console .log (response .read );
36- }
30+ const response = await client .workbooks .query (' YOUR_WORKBOOK_ID' , {
31+ read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ],
32+ });
3733
38- main ( );
34+ console . log ( response . read );
3935```
4036
4137### Request & Response types
@@ -48,12 +44,8 @@ import Grid from '@grid-is/api';
4844
4945const client = new Grid ();
5046
51- async function main() {
52- const params: Grid .WorkbookQueryParams = { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] };
53- const response: Grid .WorkbookQueryResponse = await client .workbooks .query (' YOUR_WORKBOOK_ID' , params );
54- }
55-
56- main ();
47+ const params: Grid .WorkbookQueryParams = { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] };
48+ const response: Grid .WorkbookQueryResponse = await client .workbooks .query (' YOUR_WORKBOOK_ID' , params );
5749```
5850
5951Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -95,21 +87,17 @@ a subclass of `APIError` will be thrown:
9587
9688<!-- prettier-ignore -->
9789``` ts
98- async function main() {
99- const response = await client .workbooks
100- .query (' YOUR_WORKBOOK_ID' , { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] })
101- .catch (async (err ) => {
102- if (err instanceof Grid .APIError ) {
103- console .log (err .status ); // 400
104- console .log (err .name ); // BadRequestError
105- console .log (err .headers ); // {server: 'nginx', ...}
106- } else {
107- throw err ;
108- }
109- });
110- }
111-
112- main ();
90+ const response = await client .workbooks
91+ .query (' YOUR_WORKBOOK_ID' , { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] })
92+ .catch (async (err ) => {
93+ if (err instanceof Grid .APIError ) {
94+ console .log (err .status ); // 400
95+ console .log (err .name ); // BadRequestError
96+ console .log (err .headers ); // {server: 'nginx', ...}
97+ } else {
98+ throw err ;
99+ }
100+ });
113101```
114102
115103Error codes are as follows:
0 commit comments