
Ask HN: How do I consume an API with the lowest JavaScript overhead? - dhruvkar
How do I consume an API without making a full-blown JS SPA. I need the website to be light-weight and fast loading. However, all relevant content is going to come from an API. How do I do this in the most lightweight way possible?<p>I have very little JS experience. I mostly work with Python on the backend.
======
aidos
The API already exists? The very simplest thing to do in 2020 (assuming modern
browsers) is to use fetch: [https://developer.mozilla.org/en-
US/docs/Web/API/Fetch_API/U...](https://developer.mozilla.org/en-
US/docs/Web/API/Fetch_API/Using_Fetch)

Having said that, you probably still need to think a little about auth etc.
Depends on what you're doing. If it's all internal then it's fine but
otherwise you need some notion of who the caller is and they need to send
something with each request that's checked on the python backend.

~~~
dhruvkar
The API is in process of being built.

At the moment, it's internal, but might be something I open up later.

re: auth

Should I be using oAuth? or is there something simpler with 80% the security?

~~~
aidos
Do you have interactions to worry about or are you just loading some data to
display on the page once with no further behaviour?

~~~
dhruvkar
Just loading data to display on the page. Thanks for all your help.

I see you write takeoff software -- that's pretty close to what we do. We do
the supply for builders.

