update example of typescript in README
This commit is contained in:
parent
f1e6e92f46
commit
9d45bb5ceb
22
README.md
22
README.md
@ -237,10 +237,10 @@ To connect to the API from TypeScript (e.g. Vue application) it is possible to d
|
|||||||
* Generated by APIlite
|
* Generated by APIlite
|
||||||
* https://gitea.tpsoft.org/TPsoft.org/APIlite
|
* https://gitea.tpsoft.org/TPsoft.org/APIlite
|
||||||
*
|
*
|
||||||
* 2025-05-28 15:44:07 */
|
* 2025-06-12 06:24:33 */
|
||||||
|
|
||||||
export const backend = {
|
class APIcalculator {
|
||||||
endpont: window.location.origin + "APIcalculator.php",
|
endpont = "http://";
|
||||||
|
|
||||||
/* ----------------------------------------------------
|
/* ----------------------------------------------------
|
||||||
* General API call
|
* General API call
|
||||||
@ -265,7 +265,7 @@ export const backend = {
|
|||||||
});
|
});
|
||||||
xhttp.open('POST', this.endpont + '?action=' + method);
|
xhttp.open('POST', this.endpont + '?action=' + method);
|
||||||
xhttp.send(form_data);
|
xhttp.send(form_data);
|
||||||
},
|
}
|
||||||
|
|
||||||
callPromise(method, data) {
|
callPromise(method, data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -277,34 +277,34 @@ export const backend = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------
|
/* ----------------------------------------------------
|
||||||
* API actions
|
* API actions
|
||||||
*/
|
*/
|
||||||
help() {
|
help() {
|
||||||
return this.callPromise('__HELP__', {});
|
return this.callPromise('__HELP__', {});
|
||||||
},
|
}
|
||||||
|
|
||||||
add(a, b) {
|
add(a, b) {
|
||||||
return this.callPromise('add', {a: a, b: b});
|
return this.callPromise('add', {a: a, b: b});
|
||||||
},
|
}
|
||||||
|
|
||||||
subtract(a, b) {
|
subtract(a, b) {
|
||||||
return this.callPromise('subtract', {a: a, b: b});
|
return this.callPromise('subtract', {a: a, b: b});
|
||||||
},
|
}
|
||||||
|
|
||||||
multiply(a, b) {
|
multiply(a, b) {
|
||||||
return this.callPromise('multiply', {a: a, b: b});
|
return this.callPromise('multiply', {a: a, b: b});
|
||||||
},
|
}
|
||||||
|
|
||||||
divide(a, b) {
|
divide(a, b) {
|
||||||
return this.callPromise('divide', {a: a, b: b});
|
return this.callPromise('divide', {a: a, b: b});
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default new BackendAPI();
|
||||||
```
|
```
|
||||||
|
|
||||||
These outputs can also be generated in the command line as follows
|
These outputs can also be generated in the command line as follows
|
||||||
|
Loading…
x
Reference in New Issue
Block a user