Skip to content

Commit

Permalink
Merge pull request #464 from appwrite/fix-websdk-examples
Browse files Browse the repository at this point in the history
Fix: Web SDK README
  • Loading branch information
TorstenDittmann authored Jun 22, 2022
2 parents dfe67ab + bdd94da commit c3f7957
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions templates/node/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const fs = require('fs');
{% endif %}

// Init SDK
let client = new sdk.Client();
const client = new sdk.Client();

let {{ service.name | caseCamel }} = new sdk.{{service.name | caseUcfirst}}(client);
const {{ service.name | caseCamel }} = new sdk.{{service.name | caseUcfirst}}(client);

{% if method.security|length > 0 %}
client
Expand All @@ -18,7 +18,7 @@ client
{% endfor %};

{% endif %}
let promise = {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %});
const promise = {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %});

promise.then(function (response) {
console.log(response);
Expand Down
2 changes: 1 addition & 1 deletion templates/web/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ npm install {{ language.params.npmPackage }} --save
If you're using a bundler (like [Rollup](https://rollupjs.org/) or [webpack](https://webpack.js.org/)), you can import the {{ spec.title }} module when you need it:

```js
import {{ '{' }} {{ language.params.npmPackage|caseUcfirst }} {{ '}' }} from "{{ language.params.npmPackage }}";
import {{ '{' }} Client, Account {{ '}' }} from "{{ language.params.npmPackage }}";
```

### CDN
Expand Down
10 changes: 7 additions & 3 deletions templates/web/docs/example.md.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const sdk = new {{ spec.title | caseUcfirst }}();
import {{ '{' }} Client, {{service.name | caseUcfirst}} {{ '}' }} from "{{ language.params.npmPackage }}";

const client = new Client();

const {{ service.name | caseCamel }} = new {{service.name | caseUcfirst}}(client);

{% if method.security|length > 0 %}
sdk
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
{% for node in method.security %}
{% for key,header in node|keys %}
Expand All @@ -12,7 +16,7 @@ sdk
{% endif %}
{% if method.type == 'webAuth' %}// Go to OAuth provider login page
{% endif %}
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %}let result = {% else %}let promise = {% endif %}sdk.{{ service.name | caseLower }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %});
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %}const result = {% else %}const promise = {% endif %}{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %});

{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %}console.log(result); // Resource URL{% else %}promise.then(function (response) {
console.log(response); // Success
Expand Down

0 comments on commit c3f7957

Please sign in to comment.