Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const response = await this.createRequest()
this.loading = false
this.$toasted.show(
this.__('Your profile has been saved!'),
{ type: 'success' }
)
// Reset the form by refetching the fields
this.getFields()
this.validationErrors = new Errors()
} catch (error) {
this.loading = false
if (error.response.status == 422) {
this.validationErrors = new Errors(error.response.data.errors)
}
}
},
try {
const response = await this.createRequest()
this.submittedViaCreateAndAddAnother = false
this.$toasted.show(
this.__('The :resource was created!', {
resource: this.resourceInformation.singularLabel.toLowerCase(),
}),
{ type: 'success' }
)
// Reset the form by refetching the fields
this.getFields()
this.validationErrors = new Errors()
} catch (error) {
this.submittedViaCreateAndAddAnother = false
if (error.response.status == 422) {
this.validationErrors = new Errors(error.response.data.errors)
}
}
},
const attribute = this.field.originalAttribute
const uri = this.viaRelationship
? `/nova-api/${resourceName}/${resourceId}/${relatedResourceName}/${relatedResourceId}/field/${attribute}?viaRelationship=${viaRelationship}`
: `/nova-api/${resourceName}/${resourceId}/field/${attribute}`
try {
await Nova.request().delete(uri)
this.closeRemoveModal()
this.deleted = true
this.$emit('file-deleted')
} catch (error) {
this.closeRemoveModal()
if (error.response.status == 422) {
this.uploadErrors = new Errors(error.response.data.errors)
}
}
}
}
const attribute = this.field.attribute
const uri = this.viaRelationship
? `/nova-api/${resourceName}/${resourceId}/${relatedResourceName}/${relatedResourceId}/field/${attribute}?viaRelationship=${viaRelationship}`
: `/nova-api/${resourceName}/${resourceId}/field/${attribute}`
try {
await Nova.request().delete(uri)
this.closeRemoveModal()
this.deleted = true
this.$emit('file-deleted')
} catch (error) {
this.closeRemoveModal()
if (error.response.status == 422) {
this.uploadErrors = new Errors(error.response.data.errors)
}
}
},
},
handleUpdateRequestError ({ response }) {
if (response.status === 422) {
this.validationErrors = new Errors(response.data.errors)
} else if (response.status === 409) {
this.error('Another user has updated this resource since this page was loaded. Please refresh the page and try again.')
} else {
this.requestFailed({ response } )
}
}
}
.catch(error => {
this.working = false
if (error.response.status == 422) {
this.errors = new Errors(error.response.data.errors)
}
})
},
try {
await this.withUpdating(
Nova
.request()
.post(`/nova-api/${this.resourceName}/${this.resourceId}`, formData),
)
this.closeAllModals()
this.refresh()
Nova.success(Nova.app.__('Media was updated!', { resource: this.singularLabel.toLowerCase() }))
} catch (error) {
if (!error.response) {
throw error
} else if (error.response.status === 422) {
this.__errors = new Errors(error.response.data.errors)
}
Nova.error(Nova.app.__('There was a problem submitting the form.'))
}
}
resetErrors() {
this.validationErrors = new Errors()
},
}),
{ type: 'success' }
)
this.$router.push({
name: 'detail',
params: {
resourceName: this.resourceName,
resourceId: response.data.id,
},
})
} catch (error) {
this.submittedViaCreateResource = false
if (error.response.status == 422) {
this.validationErrors = new Errors(error.response.data.errors)
}
}
},
async removeFile() {
this.uploadErrors = new Errors()
const {
resourceName,
resourceId,
relatedResourceName,
relatedResourceId,
viaRelationship
} = this
const attribute = this.field.originalAttribute
const uri = this.viaRelationship
? `/nova-api/${resourceName}/${resourceId}/${relatedResourceName}/${relatedResourceId}/field/${attribute}?viaRelationship=${viaRelationship}`
: `/nova-api/${resourceName}/${resourceId}/field/${attribute}`
try {