-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (44 loc) · 1015 Bytes
/
index.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
42
43
44
45
46
47
48
49
50
51
52
import { NhostClient } from "@nhost/nhost-js";
const nhost = new NhostClient({
backendUrl: 'https://frbscsdwzrciofdbphwf.nhost.run',
});
const request = (async () => {
// Sign in user
const signInResponse = await nhost.auth.signIn({
email: '[email protected]',
password: 'password',
})
// Handle sign-in error
if (signInResponse.error) {
throw signInResponse;
}
// Insert todo
// const { data: todo } = await nhost.graphql.request(`
// mutation insert_single_todo {
// insert_todos_one(
// object: {
// name: "Todo - 10"
// }
// ){
// id
// name
// }
// }
// `);
// console.log("Todo created with the data", todo);
// Get todos
const { data: todos } = await nhost.graphql.request(`
query {
todos {
id
created_at
name
is_completed
user_id
}
}
`);
// Print todos to console
console.log(JSON.stringify(todos, null, 2));
});
request();