I'm encountering an issue that is puzzling me:
Everything seems to be working perfectly as I try to display data from an API. However, I keep getting an error stating that personnel.departmentID
is undefined
, and unfortunately my vue-debug tool isn't providing any insights.
This error only occurs when I try to assign something from departmentID
, while for other fields like firstName, lastName, it works fine.
What's strange is that the data for departmentID.name
is displaying correctly, but still throws an error.
In the console, I see the following error:
Uncaught TypeError: _ctx.personnel.departmentID is undefined
render edit_personnel.vue:64
renderComponentRoot runtime-core.esm-bundler.js:846
componentEffect runtime-core.esm-bundler.js:4280
reactiveEffect reactivity.esm-bundler.js:42
effect reactivity.esm-bundler.js:17
setupRenderEffect runtime-core.esm-bundler.js:4263
mountComponent runtime-core.esm-bundler.js:4222
processComponent runtime-core.esm-bundler.js:4182
patch runtime-core.esm-bundler.js:3791
render runtime-core.esm-bundler.js:4883
mount runtime-core.esm-bundler.js:3077
mount runtime-dom.esm-bundler.js:1259
js personnel_edit.js:4
Webpack 7
Although the value is displayed correctly
Here is the input displayed with correct data
<input type="text" class="form-control" v-model="personnel.departmentID.name" :key="personnel.departmentID.name" />
</form>
</div>
</template>
<script>
export default {
name: "edit_personnel",
data: () => ({
personnel: [],
departments: [],
location: [],
loaded: false,
}),
async created() {
await fetch(window.currentUserId)
.then(response => response.json())
.then(data => {
this.personnel = data;
this.loaded = true;
});
}
}
</script>