eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

API calls from a specific page, every time you load the page

Open frizurd opened this issue 5 years ago • 1 comments

Hey guys, trying out Eleventy and I <3 it so far. I was just wondering if it would be possible to do an API call from a specific page, every time you load the page (instead of fetching/saving the data locally). Is this possible or does it defeat the purpose of Eleventy? If so, could someone point me in the right direction? Thank you very much for your help and time in advance.

frizurd avatar Mar 25 '20 10:03 frizurd

Well, since Eleventy (like other SSGs) is generating static files, there is no app server responding to requests (like Express.js for example). In so far, no, you can't have that on production.

You can do AJAX requests on the client-side, though. I think, that's not what you imagined, is it?

An alternative would be to trigger a FaaS (Function-as-a-Service, e.g. Netlify Functions) and have them doing $STUFF.

Ryuno-Ki avatar Mar 25 '20 13:03 Ryuno-Ki