Dear Awesome Team,
I am able to run the POST API in postman successfully, and customer gets created in my erpnext live instance as well.
Same I am trying to achieve in my VUEjs3 based application using the below code.
<template>
<div class="card text-center m-3">
<div class="card-body">New cust name: {{ product.customer_name }}</div>
<h5 class="card-header">POST Request with Set Headers</h5>
<div class="card-body">New cust company type: {{ product.company_type }}</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
const product = ref(null);
// POST request using fetch with set headers
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'token <apikey>:<apisecret>'
},
body: JSON.stringify({ customer_type: 'Company', customer_name: 'ABC' })
};
fetch('https://<liveERPNexturl>.com/api/resource/Customer', requestOptions)
.then(response => response.json())
.then(data => product.value = data);
</script>
pls suggest which part of code is failing.