-
Notifications
You must be signed in to change notification settings - Fork 1
/
skygear.js
41 lines (40 loc) · 1003 Bytes
/
skygear.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import skygear from 'skygear';
const Todo = skygear.Record.extend('todo');
export default {
getItems: (cb) => {
const query = new skygear.Query(Todo);
skygear.publicDB.query(query).then((todos) => {
cb(todos);
}, (error) => {
console.error(error);
});
},
saveItem: (text, cb) => {
skygear.publicDB.save(new Todo({
'text': text,
'completed': false
})).then((record) => {
console.log(record);
cb(record);
}, (error) => {
console.error(error);
});
},
signupAnonymously: (cb) => {
skygear.auth.signupAnonymously().then((user)=>{
console.log('logged in');
cb(user);
});
},
config: (cb) => {
skygear.config({
'endPoint': 'https://testapi20180109.skygeario.com/',
'apiKey': '4bb9cb48bab7439c97f6d033204841fc',
}).then(() => {
console.log('skygear container is now ready for making API calls.');
cb(skygear);
}, (error) => {
console.error(error);
});
}
}