@nhost/nhost-js 4.0.0 → 4.0.1
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 +9 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ The Nhost JavaScript SDK provides a client-side interface to interact with Nhost
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# npm
|
|
9
|
-
npm install @nhost/nhost-js
|
|
9
|
+
npm install @nhost/nhost-js
|
|
10
10
|
|
|
11
11
|
# yarn
|
|
12
|
-
yarn add @nhost/nhost-js
|
|
12
|
+
yarn add @nhost/nhost-js
|
|
13
13
|
|
|
14
14
|
# pnpm
|
|
15
|
-
pnpm add @nhost/nhost-js
|
|
15
|
+
pnpm add @nhost/nhost-js
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Quick Start
|
|
@@ -27,17 +27,17 @@ const nhost = createClient({
|
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
// Use authentication features
|
|
30
|
-
const
|
|
30
|
+
const signinResponse = await nhost.auth.signInEmailPassword({
|
|
31
31
|
email: 'user@example.com',
|
|
32
32
|
password: 'password123'
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (signinResponse.body.session) {
|
|
36
36
|
console.log('Signed in successfully!')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// Use GraphQL features
|
|
40
|
-
const
|
|
40
|
+
const graphqlResponse = await nhost.graphql.request({
|
|
41
41
|
query: `
|
|
42
42
|
query GetUsers {
|
|
43
43
|
users {
|
|
@@ -49,17 +49,16 @@ const response = await nhost.graphql.request({
|
|
|
49
49
|
`
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
return response.body.data.users
|
|
53
52
|
|
|
54
53
|
// Use storage features
|
|
55
|
-
const
|
|
54
|
+
const storageResponse = await nhost.storage.uploadFiles({
|
|
56
55
|
'file[]': [file]
|
|
57
56
|
})
|
|
58
57
|
|
|
59
|
-
return
|
|
58
|
+
return storageResponse.body.processedFiles[0]
|
|
60
59
|
|
|
61
60
|
// call a serverless function
|
|
62
|
-
const
|
|
61
|
+
const functionsResponse = await nhost.functions.fetch('/echo', {
|
|
63
62
|
method: 'POST',
|
|
64
63
|
body: JSON.stringify({
|
|
65
64
|
message: 'Hello, world!'
|