google-sheets-mapper 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,7 +70,7 @@ const getData = async () => {
70
70
  return await fetchGoogleSheetsData({
71
71
  apiKey: process.env.REACT_APP_GOOGLE_API_KEY,
72
72
  sheetId: process.env.REACT_APP_GOOGLE_SHEETS_ID,
73
- sheetsNames: ['Sheet1'],
73
+ sheetsOptions: [{ id: 'Sheet1' }],
74
74
  });
75
75
  } catch (error) {
76
76
  console.error(error);
@@ -84,15 +84,15 @@ const getData = async () => {
84
84
 
85
85
  The `GoogleSheetsMapper.fetchGoogleSheetsData` function takes an object with three properties:
86
86
 
87
- | Name | Value |
88
- | ----------- | ------ |
89
- | apiKey | string |
90
- | sheetId | string |
91
- | sheetsNames | array |
87
+ | Name | Value |
88
+ | ------------- | ------ |
89
+ | apiKey | string |
90
+ | sheetId | string |
91
+ | sheetsOptions | array |
92
92
 
93
93
  - `apiKey` is a Google Sheets API v4 key from [Google Cloud Console](https://console.cloud.google.com/).
94
94
  - `sheetId` is the id of the sheet.
95
- - `sheetsNames` is an array of specific sheet names. Can be left out then it will fallback to all sheets inside the spreadsheet.
95
+ - `sheetsOptions` is an array of specific objects `{ id, headerRowIndex }`. Can be left out then it will fallback to all sheets inside the spreadsheet and use first row from sheet as header.
96
96
 
97
97
  ### Exposed Data
98
98
 
@@ -109,9 +109,10 @@ try {
109
109
  }
110
110
  ```
111
111
 
112
- | Name | Value |
113
- | ---- | ----- |
114
- | data | array |
112
+ | Name | Value |
113
+ | ----- | -------------- |
114
+ | data | array |
115
+ | error | null or object |
115
116
 
116
117
  - `data` is an array of mapped data objects.
117
118
 
@@ -136,3 +137,9 @@ try {
136
137
  url: 'https://sheets.googleapis.com/v4/spreadsheets/...',
137
138
  }
138
139
  ```
140
+
141
+ ---
142
+
143
+ ## Migration from v1 to v2
144
+
145
+ - Change `sheetsNames` array of string to `sheetsOptions` array of objects with `{ id: 'sheetName' }`