0👍
A really bad way to do it is to load it async as text and use eval()
… But hey why do you load it before, wrap it into a function and call it later on?
0👍
In your index.html file, add the code below to the section
<script src="https://wchat.freshchat.com/js/widget.js"></script>
Then in your main.js file, add code below:
mounted() {
axios.get('/api/user-info')
.then((resp) => {
const user = resp.data
window.fcWidget.init({
token: "737838-363673273278-782828",
host: "https://wchat.freshchat.com",
externalId: user['id'],
firstName: user['name'],
lastName: user['surname'],
email: user['email'],
});
})
.catch((err) => {alert(err); console.log(err);})
}
}
});
Source:stackexchange.com