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.
#Experiencing syntax error unexpected token < in JSON
1 messages · Page 1 of 1 (latest)
check the network tab
getData is probably getting a 404 html page
network tab?
<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
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 try console.log(res.body.toString()) though
Ah yeah
<!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> at /import/cage/3/z5492108/comp1531/project-backend/src/server.ts:45:25<br> at Layer.handle [as handle_request] (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/layer.js:95:5)<br> at next (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/route.js:144:13)<br> at Route.dispatch (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/route.js:114:3)<br> at Layer.handle [as handle_request] (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/layer.js:95:5)<br> at /import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:284:15<br> at Function.process_params (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:346:12)<br> at next (/import/cage/3/z5492108/comp1531/project-backend/node_modules/express/lib/router/index.js:280:10)<br> at logger (/import/cage/3/z5492108/comp1531/project-backend/node_modules/morgan/index.js:144:5)<br> 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?
yes
you are importing something as import a from 'module'
and you are trying to call it (a()) but that a is not a function
is this is server.ts