I recently created an Insta-Feed in my Frontity project, and I’m happy to share my solution.
I am a beginner with JS and React, so feel free to improve it and share your opinion.
As Instagram API seemed too complicated for me, and I did not find a simple solution to communicate with it, I used Zapier RSS feed instead. You can set up a Zap-Insta-feed, as described here.
I use react-fetch-hook to get my Feed.
So first, install react-fetch-hook:
Just a quick feedback: you can use a hook for fetch like for example react-fetch-hook, because, in contrast to axios, fetch is included in the browser.
I have an ReferenceError: DOMParser is not defined at the moment if not running on Localhost but Zeit, but it will be fixed in hours… @luisherranz do you have a Parser suggestion?
But I could not do the same with react-fetch. It does have a Custom formatter, but I have no idea how to use it. In the docs it mentions a JSON formatter, and a text. My RSS feed gives back XML. So i choose text, and try to parse it with a parser.
First I did it like:
I edited my original post again, now I use Regexp to parse the XML string returned by react-fetch. I’m not a big regexp master, I hope it will be stable. Now it’s working.
No. I do not get the Insta Posts from Instagram but through Zapier RSS feed. Insta API was too complicated for me, and I did not find an easy-to-use and well-documented npm package for it.
Remember that a lot of times you can find an npm package that makes your life easier. For example, in this case, you could use something like this https://www.npmjs.com/package/simple-xml-to-json instead of regexps.
The only thing you need to make sure is that packages are small enough for client-side usage. A lot of times two package that can look alike can weight a lot more:
IMORTANT: The method described above does not working anymore (since INSTAGRAM api changes).
I came up with a new solution, but I don’t find where can I edit my original post, so I write it here:
Insta has a api like: