<template>
<div>
<form class="flex justify-center" onsubmit="return false">
<input
v-model="email"
class="input"
type="email"
placeholder="[email protected]"
/>
<button v-on:click="submit()" class="ml-3 button is-dark">Sign Up</button>
<a class="font-size-ms text-muted"></a>
</form>
<h2 class="mt-5">{{ msg }}</h2>
</div>
</template>
<script>
import axios from "axios";
export default {
props: {
apiKey: String,
},
data() {
return {
email: "",
msg: "",
};
},
methods: {
async submit() {
const currentUrl = window.location.href;
console.log(currentUrl);
console.log(this.email);
console.log(this.apiKey);
const resp = await axios.post(
`https://api.waitinglist.app/register?apiKey=${this.apiKey}`,
{
email: this.email,
url: currentUrl,
}
);
console.log(resp);
this.msg = `Your referral code is - ${resp.data.data.referralCode}`;
},
},
};
</script>
You can find the working example here