[call-me] - add API examples
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const $url = 'https://localhost:8000/api/v1/users';
|
||||
|
||||
const authorization = 'call_me_api_key_secret';
|
||||
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then((response) => response.json()) // Parse the JSON response
|
||||
.then((data) => console.log(data)) // Log the data
|
||||
.catch((error) => console.error('Error:', error)); // Handle errors
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$url = "http://localhost:8000/api/v1/users";
|
||||
|
||||
$authorization = "call_me_api_key_secret";
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
"authorization: $authorization",
|
||||
"Content-Type: application/json"
|
||||
));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
echo $response;
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
import requests # pip3 install requests
|
||||
|
||||
url = "http://localhost:8000/api/v1/users"
|
||||
|
||||
authorization = "call_me_api_key_secret"
|
||||
|
||||
headers = {
|
||||
'Authorization': authorization,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
print(response.json())
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
url = "http://localhost:8000/api/v1/users";
|
||||
|
||||
authorization="call_me_api_key_secret"
|
||||
|
||||
response=$(curl -s -X GET "$url" -H "Authorization: $authorization" -H "Content-Type: application/json")
|
||||
|
||||
echo "$response"
|
||||
Reference in New Issue
Block a user