Fix Capacitor dependencies - use built-in HTTP instead of separate plugin
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Preferences } from '@capacitor/preferences';
|
import { Preferences } from '@capacitor/preferences';
|
||||||
import { Http } from '@capacitor/http';
|
|
||||||
|
|
||||||
const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com';
|
const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com';
|
||||||
|
|
||||||
@@ -17,20 +16,19 @@ export async function syncApp(appId) {
|
|||||||
|
|
||||||
const appData = JSON.parse(value);
|
const appData = JSON.parse(value);
|
||||||
|
|
||||||
const response = await Http.request({
|
const response = await fetch(`${BACKEND_BASE_URL}/desktop/apps/sync`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `${BACKEND_BASE_URL}/desktop/apps/sync`,
|
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
data: appData,
|
body: JSON.stringify(appData),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.status < 200 || response.status >= 300) {
|
if (!response.ok) {
|
||||||
throw new Error(`Sync failed: ${response.status}`);
|
throw new Error(`Sync failed: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.data;
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runOpencodeTask(appId, taskName, args = []) {
|
export async function runOpencodeTask(appId, taskName, args = []) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"androidScheme": "https"
|
"androidScheme": "https"
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"Http": {
|
"CapacitorHttp": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"Preferences": {
|
"Preferences": {
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^5.6.0",
|
"@capacitor/android": "^5.6.0",
|
||||||
"@capacitor/core": "^5.6.0",
|
"@capacitor/core": "^5.6.0",
|
||||||
"@capacitor/preferences": "^5.0.7",
|
"@capacitor/preferences": "^5.0.7"
|
||||||
"@capacitor/http": "^5.0.7"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/cli": "^5.6.0",
|
"@capacitor/cli": "^5.6.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user