Hi I need to append below script to div tag in index.html of react. I am getting this script from backend API side
<style type='text/css'>
.helpButton .uiButton {
background-color: #005290;
font-family: "Arial", sans-serif;
}
.helpButton .uiButton:focus {
outline: 1px solid #005290;
}
</style>
<script type='text/javascript' src='.min.js'></script>
<script type='text/javascript'>
var initESW = async function (gslbBaseURL) {
embedded_svc.settings.samplesplayHelpButton = true;
embedded_svc.settings.language = '';
embedded_svc.settings.enabledFeatures = ['LiveAgent'];
embedded_svc.settings.entryFeature = 'LiveAgent';
try {
await embedded_svc.init(
'https://test--sample.my.salesforce.com',
'https://sample-test.cs81.force.com/Surveys',
gslbBaseURL,
'111111111',
'DDC_test',
{
baseLiveAgentContentURL: 'https://test.salesforceliveagent.com/content',
deploymentId: '111111111',
buttonId: '111111111',
baseLiveAgentURL: 'https://test.salesforceliveagent.com/chat',
eswLiveAgentDevName: 'test_event',
isOfflineSupportEnabled: true
}
);
}
catch (error) {
console.log(error)
}
};
if (!window.embedded_svc) {
var s = document.createElement('script');
s.setAttribute('src', 'https://test--sample.my.salesforce.com/embeddedservice/5.0/esw.min.js');
s.onload = function () {
initESW(null);
};
document.body.appendChild(s);
} else {
initESW('https://service.force.com');
}
</script>
I am able to append above script to div tag of index.html react .but it not rendring on UI. I written below code for append data to index.html
var data = API call;
document.getElementById('webchat').innerHTML = data;
My index.html have div tag with id "webchat"
<div id="webchat"></div>