How to have same backend for Flutter mobile app as of nodeJS website?
173
Just created different route for website and flutter application.
Route for website :
router.get("/api/web", (req, res) => {
res.render("home", someData)
})
Route for mob-application :
router.get("/api/app", (req, res) => {
//send response
})
Author by
kallis
Updated on December 27, 2022Comments
-
kallis over 1 year
I already have a website with nodeJS and EJS templating engine. I know I should configure my server to return data in JSON format in order to have a backend for the flutter app.
I don't have much computer background and I'm a bit confused.
Here is what I'm doing in my website codes.
router.get("/", (req, res) => { res.render("home", someData) })
-
Kidas about 3 yearsyou can create a new route like
/api/
where you will servejson
, or do you intend to sharee the same route between you webapp and flutter ? -
kallis about 3 yearsI was thinking of the same route.
-
kallis about 3 yearsBut if that's the only way, then I'll create a new route.
-
Kidas about 3 yearselse you can return
json
, and use Flutter for your webapp and mobile, like that you will share the same code https://www.filledstacks.com/post/create-and-deploy-a-flutter-web-app/ -
Wali Seddiqi over 2 yearsyou can use Dio or Http packages in Flutter in order to send request to your backend API.
-