Closed not-varram closed 8 months ago
Hi @VarshithSatti,
the problem is in line const services = require('../services');
at the top.
Download and reference this file https://github.com/armenavanesi/http-with-node/blob/master/services.js
Hi i was going down my issues and saw this. TYSM for your help hahaha and its really fun seeing how far I have gotten and how much I have learned. I am at a point right now where I could have figured this out. Again TYSM (even though it took me 2 years to see this lmfaoo)
while i run the server: `const http = require('http'); const services = require('../services'); const url = require('url');
const server = http.createServer(); server.on('request', (request, response) => { const parsedUrl = url.parse(request.url, true); if (request.method === 'GET' && parsedUrl.pathname === '/metadata') { const { id } = parsedUrl.query; const metadata = services.fetchImageMetadata(id); console.log(request.headers); } });
server.listen(8080);`
the error I get when I run it.
`D:\CODING COURCES\http_node_js>node server node:internal/modules/cjs/loader:928 throw err; ^
Error: Cannot find module '../services'`
i also did
npm i
for the dependencies"dependencies": { "axios": "^0.21.1", "body": "^5.1.0", "formidable": "1.2.0" },