37 lines
No EOL
1 KiB
TypeScript
37 lines
No EOL
1 KiB
TypeScript
import PocketBase from 'pocketbase';
|
|
|
|
const REMOTE_PB_URL = 'https://avt-back.ru';
|
|
const remotePb = new PocketBase(REMOTE_PB_URL);
|
|
|
|
// Try to get an auth token
|
|
async function main() {
|
|
console.log('Testing auth...\n');
|
|
|
|
// Try user auth
|
|
try {
|
|
await remotePb.collection('users').authWithPassword('redibedi2019@gmail.com', 'Stalin4444');
|
|
console.log('User auth: Success');
|
|
console.log('Token:', remotePb.authStore.token?.substring(0, 20) + '...');
|
|
} catch (e: any) {
|
|
console.log('User auth failed:', e.message);
|
|
}
|
|
|
|
// Check auth state
|
|
console.log('\nAuth state:');
|
|
console.log(' isValid:', remotePb.authStore.isValid);
|
|
console.log(' token exists:', !!remotePb.authStore.token);
|
|
|
|
if (remotePb.authStore.isValid) {
|
|
// Try update now
|
|
try {
|
|
await remotePb.collection('posts').update('e8or2rfsrpoly19', {
|
|
description: 'Test update'
|
|
});
|
|
console.log('\nUpdate after auth: Success!');
|
|
} catch (e: any) {
|
|
console.log('\nUpdate after auth:', e.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
main(); |