I'm struggling to construct a string that I can use with axios to fetch specific data from an API. Unfortunately, I can't seem to figure out how to use computed or mounted in this situation. The current code keeps giving me an error saying that returnurl is not defined. Any help would be greatly appreciated as I'm unsure if I am even constructing the URL correctly in the first place.
Thank you
<script>
import axios from "axios";
export default {
name: "GroupList",
data() {
return {
search: "",
groupName: this.$route.params.group,
swipedata: []
};
},
mounted() {
axios.get(returnurl).then(response => (this.swipedata = response.data));
},
computed: {
returnurl() {
return (
this.returnurl = "http://localhost:5000/" + this.$route.params.group
);
}
},
components: {}
};
</script>
Here is my router configuration for it:
{
path: "/groups/:group",
component: GroupList,
},