Answer the question
In order to leave comments, you need to log in
What is the difference between a normal and a static method in this case?
There are two files, one contains a class with cart methods:
class Cart {
fetch() {}
}
const Cart = require('../models/cart')
router.get('/', async (req, res) => {
const cart = await Cart.fetch()
})
Answer the question
In order to leave comments, you need to log in
Normal methods are defined only on the class instance, they are not on the class itself. To call such a method, the class must be instantiated.
const cart = new Cart()
await cart.fetch()
await Cart.fetch()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question