Skip to content
Advertisement

Tag: static

MIME type error with express.static and CSS files

I’m using Express and NodeJS. In my server.js file I have this piece of code: And subsequently in my static directory, I have a CSS folder, and then a style.css file. In my index.html, I link to the sheet like so: However, in my test environment I continue to get this error: Refused to apply style from ‘http://localhost:3500/static/css/style.css’ because its

JS call static method from class

I have a class with a static method: Is there an equivalent to this for static methods (i.e. refer to the current class without an instance)? So I don’t have to write the class name: “User”. Answer From MDN documentation Static method calls are made directly on the class and are not callable on instances of the class. Static methods

TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that I can’t find out how to declare static classes in TypeScript. In C#, I often use static classes to organize variables and methods, putting them together in a named class, without needing to instatiate an object. In vanilla JS, I used

Advertisement