Skip to content

Extremely simple JSON storage for web and mobile apps unit testing, with only one file.

Notifications You must be signed in to change notification settings

baguswijaksono/json-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

User Interface Preview

Few image of this web app User Interface

Add JSON Page Edit JSON Page
Add Image Edit Image
Get JSON Page Home Page
Get JSON Image Home Image
Login Page Register Page
Login Image Register Image

Fetching Data from an API

Get JSON

Parameter Description
id (int) Example: GET /?page=json&id=4

PHP Example

The PHP example demonstrates fetching data from an API using file_get_contents and handling the response.

<?php

$url = 'URL'; // Replace with your API endpoint
$response = file_get_contents($url);
if ($response === false) {
    die('Error fetching data');
}

$data = json_decode($response, true);

if ($data === null) {
    die('Error decoding JSON');
}

?>

JavaScript Example

The JavaScript example uses fetch to retrieve data from an API and handles the response asynchronously.

const apiUrl = 'URL'; // Replace with your API endpoint

fetch(apiUrl)
  .then(response => {
    if (!response.ok) {
      throw new Error(`Network response was not ok: ${response.status}`);
    return response.json();
  })
  .then(data => {
    console.log('Fetched data:', data);
  })
  .catch(error => {
    console.error('There was a problem with the fetch operation:', error);
  });

About

Extremely simple JSON storage for web and mobile apps unit testing, with only one file.

Topics

Resources

Stars

Watchers

Forks

Languages