How to receive requests?

var express = require("express");
var app = express();
var server = require("http").createServer(app);
var io = require("")(server);
var port = process.env.PORT || 3000;
const fs = require("fs");
app.get("/", (req, res) => {
	var q = url.parse(req.url, true);
	var filename = `.${q.pathname}`;
	fs.readFile(filename, (err, data) => {
		if (err) {
			res.writeHead(404, {'Content-Type': 'text/html'});
			return res.end("404 Not Found");
		res.writeHead(200, {'Content-Type': 'text/html'});
		return res.end();

error: TypeError: app.get is not a function.
So what I am trying to do is allow clients to request an profile picture from the server.

So when client changes profile picture, base64 is converted into png image that will be saved on server, then I want allow client to use url to request that image for profile picture. How I can do that?

	socket.on("account-change-avatar", (data) => {
		for (var i = 0; i <; i++) {
			if ([i].id == {
				var base64 = data.url.replace(/^data:image\/png;base64,/, "");
				fs.appendFile(`${[i].id}.png`, base64, "base64", (err) => {
					if (err) throw err;
		[i].avatar = "URL HERE";
				        socket.emit("account-refresh", "URL HERE");

Did you try using Postman/Postwoman to send a request to “/”? Also, try npm i express. I had this issue too, but don’t remember how I fixed it.

1 Like

What does npm i express do?

Try console logging app.get. app.get should be a function. Do u have express installed? Also, u didn’t seem to make the server start listening in the code you provided.

npm i express should install express. I think there’s a way to force/clean install it, like -y or something.