<template>
  <view class="pdd">
    <div class="text">
      {{ text }}
    </div>
    <input type="text" v-model="value" />
    <button @click="queryClick">点击发送</button>
  </view>
</template>

<script>
import axios from "axios";
export default {
  components: {},
  data() {
    return {
      text: "",
      value: "",
    };
  },
  computed: {},
  onShow() {},

  /**
   *
   async function query(data) {
        const response = await fetch("https://flowise.tsl3060.com/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84", {
                headers: {
                        Authorization: "Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=",
                        "Content-Type": "application/json"
                },
                method: "POST",
                body: JSON.stringify(data)
        });
        const result = await response.json();
        return result;
}
   */
  methods: {
    async query(data) {
      axios
        .post(`/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84`, data, {
          headers: {
            Authorization:
              "Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=",
            "Content-Type": "application/json",
          },
        })
        .then((response) => {
          console.log(response.data.text);
        });
    },
    queryClick() {
      const _this = this;
      this.query({
        question: _this.value,
      }).then((response) => {
        console.log(response);
      });
    },
  },
};
</script>

<style scoped lang="scss"></style>
