Skip to content

Commit 68b026b

Browse files
committed
refactor(cli): Internal client instead of a generic fetch
1 parent cc0f854 commit 68b026b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

templates/cli/lib/parser.js.twig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Table = require('cli-table3');
44
const { description } = require('../package.json');
55
const { globalConfig } = require("./config.js");
66
const os = require('os');
7+
const Client = require("./client");
78

89
const cliConfig = {
910
verbose: false,
@@ -117,12 +118,13 @@ const parseError = (err) => {
117118
if (cliConfig.report) {
118119
(async () => {
119120
let appwriteVersion = 'unknown';
120-
const isCloud = globalConfig.getEndpoint().includes('cloud.appwrite.io') ? 'Yes' : 'No';
121+
const endpoint = globalConfig.getEndpoint();
122+
const isCloud = endpoint.includes('cloud.appwrite.io') ? 'Yes' : 'No';
121123

122124
try {
123-
const res = await fetch(`${globalConfig.getEndpoint()}/health/version`);
124-
const json = await res.json();
125-
appwriteVersion = json.version;
125+
const client = new Client().setEndpoint(endpoint);
126+
const res = await client.call('get', '/health/version');
127+
appwriteVersion = res.version;
126128
} catch {
127129
}
128130

0 commit comments

Comments
 (0)