Encountering an error when attempting to call the getStocks function from a Vue component.
smileCalc:
import User from "../models/user.js";
let userID = "62e6d96a51186be0ad2864f9";
let userStocks;
async function getUserStocks() {
await User.findOne({ _id: userID }, (err, user) => {
if (user != null || user != undefined) {
userStocks = user.stocks;
}
}).clone();
};
export async function getStocks() {
await getUserStocks();
return userStocks;
}
Vue Component:
<script>
import { getStocks } from "../../../backend/scripts/smileCalc.js";
export default {
methods: {
getStocks,
},
};
</script>
<template>
<h1>User Stocks: {{ getStocks() }}</h1>
</template>
The Schema is correctly defined, exported, and imported as there are no errors upon execution of the script. However, attempts to troubleshoot by adding semicolons or changing the querying method has not resolved the issue. The TypeErrors persist despite these modifications.