Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Consuming Confluence Cloud API content in a React application

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:

  1. Confluence hosts content
  2. Application API fetches page from confluence through its API
  3. Application API forwards the response to the React application
  4. React application transforms the Confluence page's content into all the required components: tables, lists, paragraphs, images, etc

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.

1 answer

0 votes
Zak Laughton
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Feb 21, 2019

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.

Did you get help on this?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events