Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

324
Views
TypeError: Invalid value for schema Array path when using mongoose on browser

I am building a Nuxt.js application with backend and frontend integrated on the same project.

I created a /model folder with models to be used in backend and frontend.

To simplify, I have a model Address in file /model/Address.js

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const Address= new Schema ({
  country:{type:String, default:''},
  zip:{type:String, default:''},
  addr1:{type:String, default:''},
  addr2:{type:String, default:''},
  phone:{type:String, default:''},
  fax:{type:String, default:''},
  
  center_id: { type: Schema.Types.ObjectId, ref: "Center" },

});
export default (mongoose.models && mongoose.models['Address'])?mongoose.models['Address']: mongoose.model('Address', Address);

And also a AddressBook model contained in /model/AddressBook.js

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
import Address from './Address '

const AddressBook= new Schema ({
  name: { type: String, required: true,default:''},

  addresses: [Address.schema],

  center_id: { type: Schema.Types.ObjectId, ref: "Center" },

});
export default (mongoose.models && mongoose.models['AddressBook'])?mongoose.models['AddressBook']: mongoose.model('AddressBook', AddressBook);

But I am getting this error on devtools console

Uncaught TypeError: Invalid value for schema Array path addresses, got value "undefined" at Schema.add (browser.umd.js?8c0d:13972:1) at new Schema (browser.umd.js?8c0d:13517:1) at eval (Address.js?84b8:5:1) at ./model/Address.js (app.js:299:1) at webpack_require (runtime.js:854:30) at fn (runtime.js:151:20) at eval (index.js?!./node_modules/vue-loader/lib/index.js?!./components/product/EditAddress.vue?vue&type=script&lang=js&:2:87) at ./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./components/product/EditAddress.vue?vue&type=script&lang=js& (app.js:1139:1) at webpack_require (runtime.js:854:30) at fn (runtime.js:151:20)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!