Using Axios vs. GraphiQL To Import Data Into JAMstack?

I just watched the new Phil Hawksworth video on JAMstack. It is excellent. In
it he imports specific data from a news site. He uses Axios to select and import the data. Could he have used GraphiQL? What are the advantages of using Axios? Thanks.

Thanks @Engine44! Glad to hear that was helpful.

In answer to your question, yes we could certainly have used GraphQL for this sort of thing.

I used Axios and that News API as an example mostly because it was simple to explain and to demonstrate, so would not complicate the core message about the architecture. But there is nothing to stop your build or your JavaScript in the browser from querying a GraphQL API and using the returned data.

The simple type of query for content I was doing in the demo would not really require a GraphQL API. But you could totally use it. :slight_smile:

And for reference, the video being discussed here is available via FreeCodeCamp or on the Netlify blog, where I’ve posted a breakdown of what you can find where in that 3.5 hour introduction to JAMstack

Thanks. In accordance with Eleventy’s “Simpler” philosophy, I am looking for the easiest Jamstack path. Would you say that one of the above methods is easier than the other?

I’d say it depends what you are try to build/achieve.

In this example, I am not requesting complex or nested data. And I had simplistic needs for how the data was structured, so I felt it simplest to just use a data source which would give some JSON data back to a GET request.

Not every JAMstack site will need to get data from an API at all. Others might have more complex data queries that you need to support.

My personal view is to keep interfaces simple until the can’t be.

I agree. Thanks very much.

1 Like