Skip to content

Commit c32aa52

Browse files
authored
Merge pull request #194 from appwrite/improve-web-param-checking
improve(web): param checking
2 parents d0c455e + 814a8d0 commit c32aa52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

templates/web/src/sdk.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class {{ spec.title | caseUcfirst }} {
180180
{{ method.name | caseCamel }}: {% if method.type != "location" and method.type != 'webAuth'%}async <T extends unknown>{% endif %}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): {% if method.type == 'webAuth' %}void | URL{% elseif method.type == 'location' %}URL{% else %}Promise<T>{% endif %} => {
181181
{% for parameter in method.parameters.all %}
182182
{% if parameter.required %}
183-
if ({{ parameter.name | caseCamel }} === undefined) {
183+
if (typeof {{ parameter.name | caseCamel }} === 'undefined') {
184184
throw new {{spec.title | caseUcfirst}}Exception('Missing required parameter: "{{ parameter.name | caseCamel }}"');
185185
}
186186

@@ -190,7 +190,7 @@ class {{ spec.title | caseUcfirst }} {
190190
let payload: Payload = {};
191191

192192
{% for parameter in method.parameters.query %}
193-
if ({{ parameter.name | caseCamel }}) {
193+
if (typeof {{ parameter.name | caseCamel }} !== 'undefined') {
194194
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel }};
195195
}
196196

0 commit comments

Comments
 (0)