nuxt-google-sheets-parser
v1.3.4
Published
public google sheets parser for nuxt.js
Downloads
44
Maintainers
Readme
nuxt-google-sheets-parser
public google sheets parser for nuxt.js
Setup
- Add
nuxt-google-sheets-parser
dependency to your project
yarn add nuxt-google-sheets-parser
# or npm install nuxt-google-sheets-parser
- Add
nuxt-google-sheets-parser
to themodules
section ofnuxt.config.js
{
modules: [
'nuxt-google-sheets-parser'
]
}
Usage Example
- In your page or components on nuxt.js
// ...
export default {
// ...
methods: {
parseSheet (sheetId, sheetInfo = { sheetId: null, sheetName: null }) {
return this.$gsparser.parse(sheetId, sheetInfo)
}
},
async mounted () {
// see: https://docs.google.com/spreadsheets/d/10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps
const sheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps'
const data1 = await this.parseSheet(sheetId)
console.log(data1) // [{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6},{"a":7,"b":8,"c":9}]
const data2 = await this.parseSheet(sheetId, 'Sheet2')
console.log(data2) // [{"a":10,"b":20,"c":30},{"a":40,"b":50,"c":60},{"a":70,"b":80,"c":90}]
// since v1.3.0
const data3 = await this.parseSheet(sheetId, { sheetId: 1839148703 }) // or pass { sheetName: 'Sheet1' }
console.log(data3) // [{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6},{"a":7,"b":8,"c":9}]
const data4 = await this.parseSheet(sheetId, { sheetId: 784337977 }) // or pass { sheetName: 'Sheet2' }
console.log(data4) // [{"a":10,"b":20,"c":30},{"a":40,"b":50,"c":60},{"a":70,"b":80,"c":90}]
},
// ...
}
License
Copyright (c) Jihwan Oh