Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nickserv/20448820cd3a6f58666d4ad7ca60f879 to your computer and use it in GitHub Desktop.
Save nickserv/20448820cd3a6f58666d4ad7ca60f879 to your computer and use it in GitHub Desktop.
Excluding model/class properties in express
exports.postAddVehicle = ({ body }, res, next) => {
const car = new Car(body)
console.log(car)
return car
.save()
.then(() => {
res.redirect('/');
})
.catch(err => console.log(err))
}
module.exports = class Car {
constructor(data) {
this.data = data;
}
save() {
const { car_photo_url, car_price, ...body } = this.data;
return fetch(endpoint, { method: "post", body: JSON.stringify(body) });
}
}
Car {
id: null,
model_year: '2016',
make: 'Chevrolet',
model: 'Corvette',
miles: 'violet',
color: '56000',
transmission: 'automatic',
layout: 'MR',
engine_config: 'V8',
car_photo_url: undefined,
car_price: undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment