0

Neuling braucht Hilfe.API einbinden

Hallo

Bin  da etwas im dunkeln.

Kann mir einer sagen was ich da eingeben muss damit API funktioniert ?

function sendApiUpdate(period, value) {
    const apiUrl = 'https://api.ninox.com/v1/teams/[Your Team]/databases/[YOUR_DATABASE]/tables/[YOUR_TABLE]/records';
    const token =

    const requestBody = {
        period: period,
        value: value
    };

    fetch(apiUrl, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${token}`,
        },
        body: JSON.stringify(requestBody),
    })
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            console.log('Update successful', data);
            location.reload();
        } else {
            console.error('Update failed', data);
            alert('Update failed: ' + data.message);
        }
    })
    .catch(error => {
        console.error('Error:', error);
        alert('Error communicating with the API.');
    });
}
</script>

 

Danke

4 Antworten

null
    • szormpas
    • vor 8 Tagen
    • Gemeldet - anzeigen

     Hi,

    If you're looking for examples of how to use the Fetch API to communicate with the Ninox backend, you can download the latest version of the Dashboard Template (v.11.4) from the following thread:

    https://forum.ninox.com/t/p8yt8nx/dashboard-template

      • fcasoria
      • vor 7 Tagen
      • Gemeldet - anzeigen

       Thanks for the answer, but I would like to understand how the communication between CCS buttons and those of Ninox is set. For example, I would like to use CSS navigation buttons to control the date in Ninox, as well as text fields and selection fields in CSS that address Ninox tables.

    • fcasoria
    • vor 7 Tagen
    • Gemeldet - anzeigen

    stuff like this

      • szormpas
      • vor 7 Tagen
      • Gemeldet - anzeigen

         Hi,

      I'm not quite sure I understand what you're trying to do.

      Could you give me an example and maybe build a small demo database to show me?