#Experiencing syntax error unexpected token < in JSON

1 messages · Page 1 of 1 (latest)

serene flame
#

i understand this is because for some reason my code is passing htlm into the res.body but where im troubled is i dont know why. the program is a backend for a very basic quiz game website, and currently working on the clear data function, when i call the clear data in my testing it calls up this error, the clear data function is jsut supposed to return an empty object, so not sure as to why html is being output, any help is greatly appreciated.

brazen ether
#

getData is probably getting a 404 html page

serene flame
#

network tab?

brazen ether
#

oh wait this is node

#

console.log(res.body) i guess

#

oh getData isnta query

serene flame
#

<Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 0a 3c 68 74 6d 6c 20 6c 61 6e 67 3d 22 65 6e 22 3e 0a 3c 68 65 61 64 3e 0a 3c 6d 65 74 61 20 63 68 61 72 ... 1420 more bytes>

#

thats the output lmao

brazen ether
#

oh

#

res.body.toString()

#

as string is wrong

#

it's still a html string though so it's not like .toString() will help with the json parse issue

serene flame
#

still the same output

#

after changing and restarting server

brazen ether
serene flame
#

Ah yeah

serene flame
# brazen ether <@435704715754602496> try `console.log(res.body.toString())` though

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>TypeError: (0 , other_1.default) is not a function<br> &nbsp; &nbsp;at /import/cage/3/z5492108/comp1531/project-backend/src/server.ts:45:25<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at logger (/import/cage/3/z5492108/comp1531/project-backend/node_modules/morgan/index.js:144:5)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/layer.js:95:5)</pre> </body>

#

something about it not being a function?

brazen ether
#

you are importing something as import a from 'module'

#

and you are trying to call it (a()) but that a is not a function

serene flame
#

is this is server.ts