Within my repository.js file, I have the following code snippet:
async getAllContactRequests() {
return new Promise(() => {
axios
.get("http://127.0.0.1:8000/api/contactRequests", {
headers: { "Authorization": "Bearer " + sessionStorage.getItem("user_token") }
})
})
}
Meanwhile, in my Vue component, the setup is as follows:
<script>
import repository from "@/api/repository";
export default {
name: "posts-index",
data() {
return {
apiData: null,
};
},
async mounted() {
console.log("This message prints");
this.apiData = await repository.getAllContactRequests().then(result => result.data);
console.log("However, this one doesn't");
},
};
</script>
Despite the structure being sound, for some reason, the data retrieval process from the promise isn't successful and any subsequent lines of code fail to execute. What could be causing this issue?