var keystone = require('keystone'); var Application = keystone.list('Application')view.on('post', { action: 'application' }, function(next) { var newApplication = new Application.model() var updateHandler = new updateHandler(Application, newApplication, req, req.files.resume) updateHandler.process(newApplication, req.body, req.files.resume, { flashErrors: true, files: req.files.resume, fields: ['firstname', 'lastname', 'email', 'phone', 'role', 'hoursavailable', 'desiredpay', 'locationsapplied', 'startdate', 'coverletter', 'resume' ], }, function(err) { if (err) { console.log('error'); locals.validationErrors = err.detail } else { console.log('success'); locals.applicationSubmitted = true } }) }) returns TypeError: updateHandler is not a constructorFrom the docs - https://v4.keystonejs.com/api/methods/update-handler/Update Handler is a constructor from a collection of complex objects, to allow you to update an item, and return flash errors to the user. It is mostly used internally by Keystone, however if you wish to use flash errors, it is accessible. behind the scenes its process method uses the updateItem property on the passed in list. Its arguments are:Am I using this incorrectly? I'm trying to upload a file and other properties to a model without using AJAX. Is this possible? Been working on this for 4 days and not found a working solution yet
Submitted September 09, 2020 at 05:30PM by AS1272
No comments:
Post a Comment