Skip to content

React Native / Expo Examples – Health Fitness API

Access Health Fitness API in your React Native / Expo apps using fetch or axios. Both methods work seamlessly for GET and POST requests.


1. Using fetch

GET request example:

const apiKey = "YOUR_API_KEY";
const url = "https://api.hefitapi.com/api/v1/bmi?height=178&weight=82&units=metric&lang=en";

fetch(url, {
  method: "GET",
  headers: {
    "X-API-Key": apiKey
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));

POST request example:

const apiKey = "YOUR_API_KEY";
const url = "https://api.hefitapi.com/api/v1/bmi/post";

const payload = {
  height: 178,
  weight: 82,
  units: "metric"
};

fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": apiKey
  },
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));

2. Using axios

First, install axios:

npm install axios
# or
yarn add axios

GET request example:

import axios from "axios";

const apiKey = "YOUR_API_KEY";
const url = "https://api.hefitapi.com/api/v1/bmi?height=178&weight=82&units=metric&lang=en";

axios.get(url, { headers: { "X-API-Key": apiKey } })
  .then(response => console.log(response.data))
  .catch(error => console.error("Error:", error));

POST request example:

import axios from "axios";

const apiKey = "YOUR_API_KEY";
const url = "https://api.hefitapi.com/api/v1/bmi/post";

const payload = { height: 178, weight: 82, units: "metric" };

axios.post(url, payload, { headers: { "X-API-Key": apiKey } })
  .then(response => console.log(response.data))
  .catch(error => console.error("Error:", error));

Other Languages

Explore how to integrate Health Fitness API in other programming languages:

Start integrating Health Fitness API into your mobile and web apps today!


Health Fitness API Powering modern digital health infrastructure