Getting an error when resending the get request
When i send the request first time it works fine but when i send the request second time it says " Error fetching project: TypeError: The "config.server" property is required and must be of type string."
ERROR ..
19 Replies
in what file can the issue be in ?
when i sent the request first itme , it wokrs like a charm , but when i sends it again it gives this error
and when i restart the server it woks fine 1 time and again error 2nd time
First time
2nd time
I assume it's something in
db.js
and how you're instancing the connection object
i could not figure out what is causing the issue , have been trying to get it work since hours
Can you send also
projectController.js
yes i did
I think the issue is in
pool = await mssql.connect(dbConfig);
You're exporting { connectDB, sql }
; from the db.js
but sql.connect()
requires a config object as far as I can seeso how do i fix it : (
my brain is not braining anymore
😭
module.exports = { connectDB, sql, config};
probably something like thistrying
got this error
i have ot fix protery controller tooo
fixing it ...
: (
pain
i did change it in the other controller too
I just wanted to tell u that
When i start the server it starts fine
when i test the api req in the postman first time it works as expected
when i 2nd time sends a req it throws that error
@vinter. u still here bro ?
Sorry, busy with work. Will reply when I have a moment
okay np
try this maybe?
not sure why it would be undefined
like I think what was happening before was that
you were passing
{ connectDB, sql };
to mssql.connect();
which is expecting a config
instead. Maybe the library does something weird and executes the connectDB each time or something, so the second time it fails
And here that object became undefined instead so idk, probably something wrong with the exports@vinter. Thanks for the help
i found the issue here
and fixed it
so , basically it was because i was breaking the connection after every request , i was using finally block which was causing it to break
i just remvoed that block from everywhere and fixed the issue
in this u can see in last 3 lines
Oh great! Glad it works
❤️ thanks for help though !
!close
!end