Calling a FAKE API for TESTING

Have you ever just wanted to make an http request to an endpoint and get some json data?

Well you can do that using this API endpoint.

https://jsonplaceholder.typicode.com/todos/1

The API returns 

// https://jsonplaceholder.typicode.com/todos/1

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

Simply make your http call to this api.Here are a few examples.

Javascript Example
fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => console.log(json))   

C# Example
using var client = new HttpClient();
result = await client.GetAsync("https://jsonplaceholder.typicode.com/todos/1");
Console.WriteLine(result.StatusCode);

Python Example
import requests
r = request.get(url='https://jsonplaceholder.typicode.com/todos/1')
print(r.json())

Comments

Popular posts from this blog

Configuring Any .NET 9.0 Program to Run in Docker: A Step-by-Step Guide

Understand .NET 9.0 Blazor Hosting Models

Understanding a Multi-Stage Dockerfile for .NET 9 Application