[Vuejs]-Input vue Js foreign key

0👍

Your question is quite unclear, it needs a better explanation. Do you mean how to pass the 'induk_id' on axios post request. If that’s the case, it’s quite easy.

Call the submit function on vue passing the induk_id paramater whenever you want to action to be performed.

<button @click="submit(induk_id)"> Submit </button> 

Then in methods, accept the parameter and concat using template literals “

submit(id) {
        this.errors = {};
        axios.post(`/pengadaan/store_induk_pencairan/${id}`, this.userData).then(response => {
            window.location = response.data.redirect;
        }).catch(error => {
            if (error.response.status === 422) {
            this.errors = error.response.data.errors || {};
            }
        });
        }

That’s it, if its something you are looking for. But I’m not sure if you were asking about this, just my assumptions. Feel free to add more details.

0👍

<template>
  <div>{{ response_data }}</div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      formdata: {
        induk_id: "",
        nama_barang: "",
        qtt: "",
        satuan: "",
        harga: "",
        harga_total: "",
        keterangan: "",
        status: "Aktif",
      },

      response_data: null,
    };
  },
  methods: {
    submit() {
      axios
        .get(`input_detail/${this.formdata.induk_id}`)
        .then((response) => {
          this.response_data = response.data;
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
};
</script>

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

Leave a comment