Comments (4)
Hey @themixednuts, you can also do this by wrapping the call in an async function:
export const load: PageServerLoad = async ({ locals: { safeGetSession, supabase }, params: { id } }) => {
const { session } = await safeGetSession()
if (!session?.user.id) {
throw redirect(303, '/login')
}
const profile = (async () => await supabase.from('profiles').select().eq('id', id))()
// this is not part of the issue but show cases how SvelteKit wants you to handle errors on streams, but can't do this since there is no catch method. throwOnError() doesn't provide it with a catch() method either.
profile.catch(e => console.log(e))
return {
profile
}
}
from supabase-js.
Hi @themixednuts
I am not super familiar with Sveltekit so you might need to educate me a bit!
By stream, you mean streamed promise? What stops you from streaming the promise and catching on Svelte's side with {:catch}
? I might be wrong but I thought that was the recommended practice
from supabase-js.
Hi @themixednuts I am not super familiar with Sveltekit so you might need to educate me a bit!
By stream, you mean streamed promise? What stops you from streaming the promise and catching on Svelte's side with
{:catch}
? I might be wrong but I thought that was the recommended practice
All good! I think the docs will explain the best here https://kit.svelte.dev/docs/load#streaming-with-promises.
In the code side, sveltekit checks for a .catch()
on the promise, and since there is none it throws an error. So {:catch}
wouldn't even be possible even so.
from supabase-js.
Thanks for the pointer, so it looks like the call you make returns a PromiseLike
from the PostgrestBuilder
object that does not implement catch
(see here)
What you could do is map the throwOnError
to catch
for Svelte to pick up but possibly others have different ideas?
from supabase-js.
Related Issues (20)
- storage.from.list returning incorrect & incomplete data HOT 1
- PostgrestClient is not a constructor error in Edge Functions HOT 5
- Error to Logout - Inconsistent 403 Forbidden HOT 6
- bad_jwt when auth.getUser HOT 1
- auth.getUser returns an error: Auth Session Missing v2.43.2 HOT 27
- React Native IOS Session Refresh HOT 1
- Long running realtime channel results in steady growing memory
- Multiple order on table ignores 2nd order HOT 2
- Expected behavior with defaultToNull set to true in bulk inserts
- { "code": 400, "error_code": "validation_failed", "msg": "Unsupported logout scope \"window\"" } HOT 4
- Return type generation broken in 2.43.6
- supabase-js `v2.43.6`->`v2.44.0` lose auto-inferred type-safety and failing build HOT 13
- Error occur with select() HOT 2
- Failed npm install due to postinstall.js
- _index.default is undefined - Expo app from Supabase tutorial throws an error on the web HOT 3
- JS Client logs sensitive credentials to stdout/stderr
- Using this package is incompatible with TS flag exactOptionalPropertyTypes
- NEQ doesn't work on joins
- Unable to perform Google Sign In after upgrade to v2.44.4
- `createUploadSignedUrl` with upsert does not work HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-js.