As a newcomer to web development, I apologize in advance if my question seems basic or if the details provided are insufficient. Nevertheless, I hope you can assist me with the following query:
Is it possible to execute an axios.post request within a vue.js component like this?
<script>
module.exports = {
mounted() {
// game code
};
</script>
My current issue revolves around not being able to import axios using import axios from "axios";
. Additionally, utilizing export default { ... }
leads to page errors (specifically a TypeError: "exports" is read-only). Nonetheless, I urgently need to access a variable within the game code so that I can post that data (game score along with additional JSON info) to my MongoDB database using axios.post.
If making the request directly from the `mounted() { // game code };
` block is unfeasible, could I extract a variable from that section and transfer it to another component for posting? Despite conducting extensive research online for several hours, none of the solutions seem to work in my case. Therefore, please excuse any appearance of laziness as it stems merely from sheer frustration over unsuccessful attempts to find a resolution.