import { createSession } from 'wreq-js';
const session = await createSession({
browser: 'chrome_142',
os: 'windows',
proxy: 'http://proxy.example.com:8080',
});
try {
await session.fetch('https://example.com/login', {
method: 'POST',
body: new URLSearchParams({ user: 'name', pass: 'secret' }),
});
const ws = await session.websocket('wss://example.com/ws', {
headers: {
'X-Client': 'dashboard',
},
});
ws.onmessage = (event) => {
console.log(event.data);
};
void ws.send(JSON.stringify({ type: 'subscribe', channel: 'updates' }));
ws.close(1000, 'done');
} finally {
await session.close();
}