Setting api data to strapi

Hello everyone, maybe it’s a dumb question, but how do I can set the data from a third-party api to strapi. Data that comes from an api is large, so I don’t want to set it manually. I want to add additional fields to data from api, that’s why I don’t just fetch it directly. I’m building my project with next js

You should the Strapi Content API (usually POST requests) to send the transformed data to your Strapi server and save it in the corresponding model.

Here’s a simplified example using JavaScript:
// Example Next.js script to fetch data and send it to Strapi

const fetchDataFromApi = async () => {
try {
// Fetch data from the third-party API
const response = await fetch(‘https://api.example.com/data’);
const data = await response.json();

// Transform and enhance data
const transformedData = data.map(item => ({
  // Add your additional fields here
  additionalField: 'example',
  ...item,
}));

// Send data to Strapi
const strapiResponse = await fetch('http://localhost:1337/api-endpoint', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    // Add any additional headers if needed
  },
  body: JSON.stringify(transformedData),
});

const strapiData = await strapiResponse.json();
console.log('Data sent to Strapi:', strapiData);

} catch (error) {
console.error(‘Error fetching or sending data:’, error);
}
};

// Call the function to initiate the process
fetchDataFromApi();

Remember to replace 'https://api.example.com/data' with the actual URL of the third-party business information api and 'http://localhost:1337/api-endpoint' with the appropriate endpoint in your Strapi server.