Skip to content

Commit 08f667a

Browse files
author
Daniele Briggi
committed
feat: support to https connection string and JWT token
1 parent 900d647 commit 08f667a

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

examples/to-do-app/hooks/useCategories.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect } from 'react'
22
import { Platform } from 'react-native';
33
import { db } from "../db/dbConnection";
4-
import { CONNECTION_STRING } from "@env";
4+
import { CONNECTION_STRING, API_TOKEN } from "@env";
55
import { getDylibPath } from "@op-engineering/op-sqlite";
66
import { randomUUID } from 'expo-crypto';
77
import { useSyncContext } from '../components/SyncContext';
@@ -69,11 +69,8 @@ const useCategories = () => {
6969
await db.execute('INSERT OR IGNORE INTO tags (uuid, name) VALUES (?, ?)', [randomUUID(), 'Work'])
7070
await db.execute('INSERT OR IGNORE INTO tags (uuid, name) VALUES (?, ?)', [randomUUID(), 'Personal'])
7171

72-
if (CONNECTION_STRING && CONNECTION_STRING.startsWith('sqlitecloud://')) {
73-
await db.execute(`SELECT cloudsync_network_init('${CONNECTION_STRING}');`);
74-
} else {
75-
throw new Error('No valid CONNECTION_STRING provided, cloudsync_network_init will not be called');
76-
}
72+
await db.execute(`SELECT cloudsync_network_init('${CONNECTION_STRING}');`);
73+
await db.execute(`SELECT cloudsync_network_set_token('${API_TOKEN}');`)
7774

7875
db.execute('SELECT cloudsync_network_sync(100, 10);')
7976
getCategories()

0 commit comments

Comments
 (0)