Please use https://github.com/sheetbase/angular instead.
Angular module for using Sheetbase in Angular/Ionic projects.
npm install --save sheetbase-angular
Import SheetbaseModule to your app.module.ts.
import { SheetbaseModule } from 'sheetbase-angular';
import { SHEETBASE_CONFIG } from '../configs/sheetbase.config';
imports: [
SheetbaseModule.forRoot(SHEETBASE_CONFIG)
]
Inject services into your page.
import { DataService } from 'sheetbase-angular';
constructor(
private sheetbaseData: DataService
) {}
ngOnInit() {
this.sheetbaseData.get('posts')
.subscribe(posts => {
console.log('My posts: ', posts);
});
}
There are 2 ways to config the module.
Get data directly from Google API.
Key | Type | Description |
---|---|---|
googleApiKey | string | Google API Key |
databaseId | string | ID of database spreadsheet |
Using backend to get data and other functions.
Key | Type | Description |
---|---|---|
apiKey | string | Backend API Key |
backendUrl | string | Backend URL |
Key | Type | Description |
---|---|---|
modifiers | object | Custom modifying data |
get(collection: string, doc: string = null, query: IDataQuery = null)
Get data from database.
this.sheetbaseData.get('posts', 'post-1')
.subscribe(post1 => {
console.log(post1);
});
GET(endpoint: string = null, params: any = {})
Request GET method.
this.sheetbaseApi.GET('/data', {
apiKey: 'my_api_key',
table: 'posts'
})
.subscribe(posts => {
console.log(posts);
});
POST(endpoint: string = null, params: any = {}, body: any = {})
Request POST method.
this.sheetbaseApi.POST('/user/create', {}, {
apiKey: 'my_api_key',
email: '[email protected]',
password: 'password'
})
.subscribe(profile => {
console.log(profile);
});
getToken()
Get user id token.
this.sheetbaseUser.getToken()
.subscribe(token => {
console.log(token);
});
getUser()
Get user data.
this.sheetbaseUser.getUser()
.subscribe(profile => {
console.log(profile);
});
onAuthStateChanged()
Event of user authentication status.
this.sheetbaseUser.onAuthStateChanged()
.subscribe(profile => {
console.log(profile);
});
createUserWithEmailAndPassword(email: string, password: string)
Register new user by email and password.
this.sheetbaseUser.createUserWithEmailAndPassword(
'[email protected]',
'password'
)
.subscribe(profile => {
console.log(profile);
});
signInWithEmailAndPassword(email: string, password: string)
Log user in by using email and password.
this.sheetbaseUser.signInWithEmailAndPassword(
'[email protected]',
'password'
)
.subscribe(profile => {
console.log(profile);
});
signOut()
Log user out.
this.sheetbaseUser.signOut()
.subscribe(() => {
console.log('You are out!');
});
updateProfile(profile: any)
Update user profile.
this.sheetbaseUser.updateProfile({
displayName: 'My Name',
tel: '+1 2345 6789'
})
.subscribe(profile => {
console.log(profile);
});
sendPasswordResetEmail(email: string)
Ask for password reset email.
this.sheetbaseUser.sendPasswordResetEmail('[email protected]')
.subscribe(() => {
console.log('Email sent!');
});
confirmPasswordReset(oobCode: string, password: string)
Change user password.
this.sheetbaseUser.confirmPasswordReset(
'my_oob_code',
'new-password'
)
.subscribe(() => {
console.log('Cool! Please login with your new password!');
});
applyActionCode(oobCode: string)
Verify out-of-band code.
this.sheetbaseUser.applyActionCode('my_oob_code')
.subscribe(() => {
console.log('Valid!');
});
get(fileId: string)
Get file information by id.
this.sheetbaseFile.get('file_id')
.subscribe(fileInfo => {
console.log(fileInfo);
});
upload(appFile: IAppFile, customFolder: string = null)
Upload a file.
this.sheetbaseFile.upload({
name: 'file.txt',
mimeType: 'text/plain',
base64String: 'Ab73Ajdwk...'
})
.subscribe(fileInfo => {
console.log(fileInfo);
});
load(file: File)
Load local file.
this.sheetbaseFile.load(localFile)
.subscribe(localFileInfo => {
console.log(localFileInfo);
});
Please visit https://sheetbase.net/ for more.