@libsql/client@0.6.1 always returns 400 error when trying to fetch data from the server
sunsetplaty opened this issue · comments
I am encountering an issue when using the @libsql/client@0.6.1 library.
It always returns a 400 Bad Request error when I try to execute a query.
The result is okay and I can see the data, but the 400 error is always there.
my code
import { config } from 'dotenv';
config();
import { createClient } from '@libsql/client';
async function example() {
const client = createClient({
url: process.env.TURSO_CONNECTION_URL,
authToken: process.env.TURSO_AUTH_TOKEN
});
const result = await client.execute("SELECT * FROM users");
for (const row of result.rows) {
console.log(" - " + row.email);
}
}
example();
result
url: https://MY_PERSONAL_ACCOUNT.turso.io/v1/jobs
result: Response {
status: 400,
statusText: 'Bad Request',
headers: Headers {
'access-control-allow-origin': '*',
'content-type': 'application/json',
date: 'Sat, 01 Jun 2024 00:53:48 GMT',
'fly-request-id': '01HZ8MKNS0ZQESBHQ384DKVS65-nrt',
server: 'Fly/63a16321 (2024-05-30)',
vary: 'origin, access-control-request-method, access-control-request-headers',
via: '2 fly.io, 1.1 fly.io',
'transfer-encoding': 'chunked',
'content-encoding': 'br'
},
body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
bodyUsed: false,
ok: false,
redirected: false,
type: 'basic',
url: 'https://MY_PERSONAL_ACCOUNT.turso.io/v1/jobs'
}
- hello@example.com
When I run a similar query using an HTTP request based on Turso's HTTP quickstart guide, it works fine. This suggests the issue might be related to the @libsql/client@0.6.1 library or the v1 API?
Hey @sunsetplaty, thanks for report this. Effectively this was an issue happening on 0.6.1
. We release a fix for it on 0.6.2
so feel free to upgrade when you can 🙂
Let me know if you have any other issues and I'll help you as soon as possible!
@giovannibenussi Thanks for the quick fix! I updated to 0.6.2 and the issue is resolved.