Express kütüphanesi için @Akif9748 hocamın GitHub'ında bulunan bir Repo'dan "Route Handler" aldım.
[CODE title="Handler"]for (const type of fs.readdirSync("./routes"))
for (const file of fs.readdirSync("./routes/" + type))
console.log(file)
app[type](`/${file.replace(".js", "")}*`, require(`./routes/${type}/${file}`))[/CODE]
Her seferinde "TypeError: App[type] is not a function" hatası alıyorum.
Nasıl düzeltebilirim? Neyi yanlış yapıyorum?
Ben /routes klasörü altına oluşturduğum dosyalar "GET" ve "POST" adına sahipti. Sonra aklıma geldi...
app.GET() değil app.get() olması lazım. Yani sorun büyük harf olmasıymış. Çözdüm sonunda!
[CODE title="Handler"]for (const type of fs.readdirSync("./routes"))
for (const file of fs.readdirSync("./routes/" + type))
console.log(file)
app[type](`/${file.replace(".js", "")}*`, require(`./routes/${type}/${file}`))[/CODE]
Her seferinde "TypeError: App[type] is not a function" hatası alıyorum.
Nasıl düzeltebilirim? Neyi yanlış yapıyorum?
Ben /routes klasörü altına oluşturduğum dosyalar "GET" ve "POST" adına sahipti. Sonra aklıma geldi...
Son düzenleme: