Greetings,
I was wondering what practises are available out there to transform a Confluence Cloud API call, say to fetch a specific page's content, into a React component. Basically:
I have played around with the `xml-js` library, but its implementation is quite messy. I was wondering if perhaps there was something better out there.
Hi Virginia,
The process of using the Confluence API in a React component should be similar to using any other API with React. The React documentation has some great info and details: React - AJAX and APIs.
As for parsing the page content, you could try just using .match() and regex. This StackOverflow post also has a pretty good suggestion to turn the JSON response string into an HTML DOM element, which you can then parse with .querySelector() (or .querySelectorAll()) to find whatever elements you're looking for.
I hope this helps!
– Zak
Thank you for your answer.
Although that method doesn't quite work for my use case. I am parsing a Confluence page that returns its content in XML into fully fledged React components.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you get help on this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.