May 23, 2024, 8:13 p.m. | antonmak1

DEV Community dev.to

Perhaps it will help someone. You can use the cample-html package to load HTML from the server. It works on fetch, so it can help you avoid writing a bunch of code:



<div>
<template
data-cample
data-src="/api/text"
data-method="get"
>
</template>
</div>
<script src="https://unpkg.com/cample-html"></script>


Or, if you need to work through javascript, you can use the createTemplate method:



<script src="https://unpkg.com/cample-html"></script>
<script>
const templateFn = CampleHTML.createTemplate(
`<template data-cample data-src="/api/test" data-method="get"></template>`
);

const wrapper = document.getElementById("wrapper");

const elementObj = templateFn({
credentials: "same-origin",
get: (prop, …

api beginners code data fetch html javascript package programming server template text through webdev will work writing

Senior Data Engineer

@ Displate | Warsaw

Junior Data Analyst - ESG Data

@ Institutional Shareholder Services | Mumbai

Intern Data Driven Development in Sensor Fusion for Autonomous Driving (f/m/x)

@ BMW Group | Munich, DE

Senior MLOps Engineer, Machine Learning Platform

@ GetYourGuide | Berlin

Data Engineer, Analytics

@ Meta | Menlo Park, CA

Data Engineer

@ Meta | Menlo Park, CA