fszabo
fszabo
TTCTheo's Typesafe Cult
Created by fszabo on 7/5/2023 in #questions
Does App Router have getStaticPaths? Does it even need that?
Hello everybody! 👋 I hope you are well! So I'm looking into App Router. I just recently followed the Nextjs Guide and set up a basic blog, put using Pages. Now I'm trying to figure out how to migrate 😅 Pages had this apparently super cool feature to pre-generate my blog posts during the build with getStaticPaths and getStaticProps. I can't seem to find anything like that in App Router, although I'm really unsure if that's even still necessary. Does App Router have something like getStaticPaths? Does it even need that? What's the best way of serving my .md files (blog posts) with remark with App Router? 🤔 Thanks in advance! Answers are much appreciated 🙂
7 replies
TTCTheo's Typesafe Cult
Created by fszabo on 5/10/2023 in #questions
prisma.update returns promise but doesn't do anything (most of the time)
As described in the title, prisma.update does not reliably trigger an update in the database. This is the gist of my code:
.middleware(...) //<-- works just fine
.onUploadComplete(({ file }) => {
console.log("on upload complete") // <-- works just fine
try {
const promise = prisma.plant.update({ // <-- returns a promise
where: { imageUrl: file.url },
data: {
imageStatus: "done",
},
});
console.log("update was called") // <-- works just fine
console.log(promise) // <-- works just fine
void promise
.then(() => console.log("update complete")) // <-- I only get here 1/3 times
.catch((err) => console.error("update failed")) // <-- I **sometimes** get here if I refresh the page before all updates are complete
}
catch (err) {
console.error(err) // <-- no errors are caught here
}
}
.middleware(...) //<-- works just fine
.onUploadComplete(({ file }) => {
console.log("on upload complete") // <-- works just fine
try {
const promise = prisma.plant.update({ // <-- returns a promise
where: { imageUrl: file.url },
data: {
imageStatus: "done",
},
});
console.log("update was called") // <-- works just fine
console.log(promise) // <-- works just fine
void promise
.then(() => console.log("update complete")) // <-- I only get here 1/3 times
.catch((err) => console.error("update failed")) // <-- I **sometimes** get here if I refresh the page before all updates are complete
}
catch (err) {
console.error(err) // <-- no errors are caught here
}
}
Additionally, I have enabled prisma query logs in production: ["query", "error", "warn"] Any ideas on what's going on? Please let me know if there's more information I should provide.
4 replies
TTCTheo's Typesafe Cult
Created by fszabo on 5/9/2023 in #questions
Can someone explain the difference between page router and app router?
create-t3-app is using page router at the moment as far as I can tell, but the app router seems to be the latest thing. What's the difference? Should I switch? When do I switch? How do I switch? Does it even matter? I suppose it's not that important as long as create-t3-app is still using page router? Please excuse me if these are stupid questions lol
4 replies