Mads
Mads
Explore posts from servers
NNuxt
Created by Jonas on 9/28/2024 in #❓・help
Couldn't resolve component "default" at "/"
No description
18 replies
NNuxt
Created by Bobbo on 10/11/2024 in #❓・help
Upgrading from 3.5.0 to 3.13.2 is breaking build
useId is a Vue 3.5 thing. Try installing the latest version of Vue
14 replies
DTDrizzle Team
Created by BEEIRL on 8/23/2024 in #help
PlanetScale drizzle-kit push: Cannot drop index: needed in a foreign key constraint
I experience the same.
3 replies
DTDrizzle Team
Created by theo (t3.gg) on 9/3/2024 in #help
Consistent issues with `drizzle-kit push` on Turso
I appreciate it, thanks Andrew. Let me know if there is anything I can do.
24 replies
DTDrizzle Team
Created by theo (t3.gg) on 9/3/2024 in #help
Consistent issues with `drizzle-kit push` on Turso
Sorry for hijacking. Any chance we can get Push to work on Planetscale working again @Andrew Sherman 🙂 https://github.com/drizzle-team/drizzle-orm/issues/2599 I can provide a Planetscale database if you need it for testing.
24 replies
DTDrizzle Team
Created by Mads on 8/31/2024 in #help
notNull and Unique
7 replies
DTDrizzle Team
Created by Mads on 8/31/2024 in #help
notNull and Unique
Well that added the unique constraint. But it still complaints about I’m about to add a new unique constraint.
7 replies
DTDrizzle Team
Created by Mads on 8/31/2024 in #help
notNull and Unique
Moving unique() to the end fixed it: name: varchar('name', { length: 255 }).notNull().unique(),
7 replies
DTDrizzle Team
Created by Mads on 8/31/2024 in #help
notNull and Unique
No description
7 replies
NNuxt
Created by Pawieplays on 8/26/2024 in #❓・help
Metadata for Route
Or maybe be wrong. You want to do a navigation and pass some data along, without setting a query? It seems like the wrong approach. I would look into using setting a useState or maybe definePageMeta like so. definePageMeta({ pageType: 'Checkout', })
3 replies
NNuxt
Created by Pawieplays on 8/26/2024 in #❓・help
Metadata for Route
You still can using definePageMeta.
3 replies
NNuxt
Created by Gregor on 8/27/2024 in #❓・help
pretty urls for e-commerce shop
Why not use a folder structure like this /[category]/[subcategory]/[subsubcategory]/[product] It sounds like you need to define a structure. Also use useRouter() to extract the queries and params. Much easier.
3 replies
NNuxt
Created by isakwang on 8/27/2024 in #❓・help
Non fatal server error
You should probably set ignoreResponseError to true. Assuming you use $fetch (useFetch) await $fetch('/api/used-cars/all', { method: 'GET', ignoreResponseError: true, })
7 replies
NNuxt
Created by Josh Deltener on 8/26/2024 in #❓・help
Is there a way to NOT show an HTML error from an API?
But yes, as you mentioned I do set the responseStatus. The createError is a suboptimal solution imo.
8 replies
NNuxt
Created by Josh Deltener on 8/26/2024 in #❓・help
Is there a way to NOT show an HTML error from an API?
Then I use it something like this
try {
const response = await $fetch('/api/used-cars/all', {
method: 'GET',
ignoreResponseError: true,
})

if (response && 'value' in response) {
return response.value.used_cars
}
else {
if (response.error._tag === 'UnauthorizedError') {
toast.add({ title: 'Du er ikke autoriseret', description: 'Du er måske ikke logget ind, eller har ikke autorisation til at oprette en prisprotokol', color: 'red' })
}
try {
const response = await $fetch('/api/used-cars/all', {
method: 'GET',
ignoreResponseError: true,
})

if (response && 'value' in response) {
return response.value.used_cars
}
else {
if (response.error._tag === 'UnauthorizedError') {
toast.add({ title: 'Du er ikke autoriseret', description: 'Du er måske ikke logget ind, eller har ikke autorisation til at oprette en prisprotokol', color: 'red' })
}
8 replies
NNuxt
Created by Josh Deltener on 8/26/2024 in #❓・help
Is there a way to NOT show an HTML error from an API?
import { and, eq } from 'drizzle-orm'
import { Err, Ok } from 'ts-results-es'
import { used_cars } from '@/../server/database/core-schema'

export default defineEventHandler(async (event) => {
if (!event.context.session) {
setResponseStatus(event, 401, 'You are not logged in')
return new Err({ _tag: 'UnauthorizedError', message: 'You are not logged in' } as const)
}
if (!event.context.user) {
setResponseStatus(event, 401, 'Could not find user')
return new Err({ _tag: 'UnauthorizedError', message: 'Could not find user' } as const)
}

const user = event.context.user

if (!user.selected_company_id) {
setResponseStatus(event, 401, 'User has no selected company')
return new Err({ _tag: 'NoSelectedCompanyError', message: 'User has no selected company' } as const)
}

try {
const cars = await useDB().query.used_cars.findMany({
where: and(
eq(used_cars.company_id, user.selected_company_id),
),
}).execute()

return new Ok({
_tag: 'Success',
message: 'Used cars found',
used_cars: cars,
} as const)
}
catch (error) {
console.error(error)
setResponseStatus(event, 500, 'Failed to fetch used cars')
return new Err({ _tag: 'DatabaseFetchError', message: 'Failed to fetch used cars', error } as const)
}
})
import { and, eq } from 'drizzle-orm'
import { Err, Ok } from 'ts-results-es'
import { used_cars } from '@/../server/database/core-schema'

export default defineEventHandler(async (event) => {
if (!event.context.session) {
setResponseStatus(event, 401, 'You are not logged in')
return new Err({ _tag: 'UnauthorizedError', message: 'You are not logged in' } as const)
}
if (!event.context.user) {
setResponseStatus(event, 401, 'Could not find user')
return new Err({ _tag: 'UnauthorizedError', message: 'Could not find user' } as const)
}

const user = event.context.user

if (!user.selected_company_id) {
setResponseStatus(event, 401, 'User has no selected company')
return new Err({ _tag: 'NoSelectedCompanyError', message: 'User has no selected company' } as const)
}

try {
const cars = await useDB().query.used_cars.findMany({
where: and(
eq(used_cars.company_id, user.selected_company_id),
),
}).execute()

return new Ok({
_tag: 'Success',
message: 'Used cars found',
used_cars: cars,
} as const)
}
catch (error) {
console.error(error)
setResponseStatus(event, 500, 'Failed to fetch used cars')
return new Err({ _tag: 'DatabaseFetchError', message: 'Failed to fetch used cars', error } as const)
}
})
8 replies
NNuxt
Created by Josh Deltener on 8/26/2024 in #❓・help
Is there a way to NOT show an HTML error from an API?
Hi Josh. I recently went through same frustration. Here’s how I handle it:
8 replies
NNuxt
Created by tsi-trevor on 5/14/2024 in #❓・help
How can I remove a route parameter value?
Remember to use await or return
4 replies
NNuxt
Created by tsi-trevor on 5/14/2024 in #❓・help
How can I remove a route parameter value?
or navigateTo({ path: ‘/foo’})
4 replies
NNuxt
Created by 83inc on 5/15/2024 in #❓・help
Amateur Looking for Help Making POST to MySQL Using Nuxt 3
Would you be able to post it as a Gist or just add the code in here? But from just reading your post I would assume your connection to the Nitro backend is fine and gets called when you want it to. It seems like the data it receives could be wrong. I would debug here first, throw in some console logs to see what it catches. Does it receive your body data? If it does, onto next issue. Other than that, I would highly recommend Drizzle or Prisma as it would give you some better error logs on what goes wrong.
2 replies