Getting started with Vue
1. Install and import the @botpoison/browser library.
npm install @botpoison/browser
2. Create a new Botpoison instance with your public key.
3. Process a challenge using the challenge() function.
4. Forward the solution to your server for verification.
markup
<template><div><form @submit.prevent="onSubmit"><textarea v-model="message" placeholder="Enter your message" /><button type="submit" :disabled="loading">Send</button></form></div></template><script>import axios from "axios";// 1. Import the libraryimport Botpoison from "@botpoison/browser";export default {data() {return {botpoison: null,message: null,loading: false,};},created() {// 2. Create a new instance with your public keythis.botpoison = new Botpoison({publicKey: "pk_xxxxxxxx",});},methods: {async onSubmit() {this.loading = true;try {// 3. Process a challengeconst { solution } = await this.botpoison.challenge();await axios.post("https://example.demo/", {message: this.message,// 4. Forward the solution_botpoison: solution,});alert("Form submitted");this.message = null;} catch (error) {alert("Error submitting form");} finally {this.loading = false;}},},};</script>