Skip to content

Commit

Permalink
Replace defunct http test service mockbin.org
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Nov 5, 2023
1 parent 61eb46a commit d24f441
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 357 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Create a resource for the planet Jupiter:
const resource = { name: 'Jupiter', position: 5 };
const handleData = (data) =>
console.log('New planet:', data); //http response body as an object literal
fetchJson.post('https://mockbin.org/request', resource)
fetchJson.post('https://centerkey.com/rest/', resource)
.then(handleData)
.catch(console.error);
```
Expand Down Expand Up @@ -109,7 +109,7 @@ Create a resource for the planet Jupiter:
```javascript
// Create Jupiter
const create = async (resource) => {
const data = await fetchJson.post('https://mockbin.org/request', resource);
const data = await fetchJson.post('https://centerkey.com/rest/', resource);
console.log('New planet:', data); //http response body as an object literal
};
create({ name: 'Jupiter', position: 5 });
Expand All @@ -135,7 +135,7 @@ const options = {
};
const handleData = (data) =>
console.log(data); //http response body as an object literal
fetch('https://mockbin.org/request', options)
fetch('https://centerkey.com/rest/', options)
.then(response => response.json())
.then(handleData)
.catch(console.error);
Expand Down
4 changes: 2 additions & 2 deletions docs/js/examples-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const example = {

// Create Jupiter
const resource = { name: 'Jupiter', position: 5 };
const data = await fetchJson.post('https://mockbin.org/request', resource)
const data = await fetchJson.post('https://centerkey.com/rest/', resource)
.catch(console.error);
console.log('New planet:', data);

Expand All @@ -47,7 +47,7 @@ const example = {
teapot: async () => {

// Fetch me some tea
const data = await fetchJson.get('https://centerkey.com/status/418/');
const data = await fetchJson.get('https://centerkey.com/rest/status/418/');
console.log(data.bodyText);

},
Expand Down
4 changes: 2 additions & 2 deletions docs/js/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const example = {
// Create Jupiter
const resource = { name: 'Jupiter', position: 5 };
const handleData = (data) => console.log('New planet:', data);
fetchJson.post('https://mockbin.org/request', resource)
fetchJson.post('https://centerkey.com/rest/', resource)
.then(handleData)
.catch(console.error);

Expand All @@ -49,7 +49,7 @@ const example = {

// Fetch me some tea
const handleData = (data) => console.log(data.bodyText);
fetchJson.get('https://centerkey.com/status/418/').then(handleData);
fetchJson.get('https://centerkey.com/rest/status/418/').then(handleData);

},

Expand Down
85 changes: 32 additions & 53 deletions docs/js/examples.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,53 @@

Examples
========
fetch-json v3.1.1
fetch-json v3.2.1

2023-06-28T08:59:53.211Z request GET api.nasa.gov https://api.nasa.gov/planetary/apod
2023-06-28T08:59:53.255Z request POST mockbin.org https://mockbin.org/request
2023-06-28T08:59:53.257Z request GET centerkey.com https://centerkey.com/status/418/
2023-06-28T08:59:53.259Z request GET www.googleapis.com https://www.googleapis.com/books/v1/volumes
2023-06-28T08:59:53.564Z response POST mockbin.org https://mockbin.org/request true 200 OK application/json; charset=utf-8
2023-06-28T08:59:53.571Z response GET centerkey.com https://centerkey.com/status/418/ false 418 I'm a teapot text/plain
New planet: {
startedDateTime: '2023-06-28T08:59:53.533Z',
clientIPAddress: '2600:1700:dcd0:b270:95c7:f607:347:a7b1',
method: 'POST',
url: 'https://mockbin.org/request',
httpVersion: 'HTTP/1.1',
cookies: {},
headers: {
host: 'mockbin.org',
connection: 'close',
'accept-encoding': 'gzip',
'x-forwarded-for': '2600:1700:dcd0:b270:95c7:f607:347:a7b1, 172.71.159.7',
'cf-ray': '7de4bc7acd34cff9-SJC',
'x-forwarded-proto': 'http',
'cf-visitor': '{"scheme":"https"}',
accept: 'application/json',
'content-type': 'application/json',
'accept-language': '*',
'sec-fetch-mode': 'cors',
'user-agent': 'undici',
'cdn-loop': 'cloudflare',
'cf-connecting-ip': '2600:1700:dcd0:b270:95c7:f607:347:a7b1',
'x-request-id': '604767e3-f78d-47ba-9a24-ad4a7b716208',
'x-forwarded-port': '80',
via: '1.1 vegur',
'connect-time': '0',
'x-request-start': '1687942793534',
'total-route-time': '0',
'content-length': '31'
},
queryString: {},
postData: {
mimeType: 'application/json',
text: '{"name":"Jupiter","position":5}',
params: []
},
headersSize: 641,
bodySize: 31
}
2023-11-05T09:21:21.442Z request GET api.nasa.gov https://api.nasa.gov/planetary/apod
2023-11-05T09:21:21.500Z request POST centerkey.com https://centerkey.com/rest/
2023-11-05T09:21:21.505Z request GET centerkey.com https://centerkey.com/rest/status/418/
2023-11-05T09:21:21.507Z request GET www.googleapis.com https://www.googleapis.com/books/v1/volumes
2023-11-05T09:21:21.834Z response GET api.nasa.gov https://api.nasa.gov/planetary/apod true 200 OK application/json
2023-11-05T09:21:21.843Z response GET centerkey.com https://centerkey.com/rest/status/418/ false 418 I'm a teapot text/plain;charset=UTF-8
The NASA APoD for today is at: https://apod.nasa.gov/apod/image/2311/CreatureAurora_Salomonsen_960.jpg
;,'
_o_ ;:;'
,-.'---`.__ ;
((j`=====',-'
`-\ /
`-=-' hjw
2023-06-28T08:59:53.987Z response GET www.googleapis.com https://www.googleapis.com/books/v1/volumes true 200 OK application/json; charset=UTF-8

2023-11-05T09:21:21.858Z response POST centerkey.com https://centerkey.com/rest/ true 200 OK application/json
New planet: {
headers: {
'Content-Length': '31',
'Content-Type': 'application/json',
Accept: 'application/json',
'Accept-Encoding': 'br, gzip, deflate',
'Accept-Language': '*',
Connection: 'keep-alive',
Host: 'centerkey.com',
'Sec-Fetch-Mode': 'cors',
'User-Agent': 'node'
},
method: 'POST',
query: '',
params: {},
body: { name: 'Jupiter', position: 5 }
}
2023-11-05T09:21:22.096Z response GET www.googleapis.com https://www.googleapis.com/books/v1/volumes true 200 OK application/json; charset=UTF-8
SpaceX books:
[
'SpaceX',
'SpaceX',
"SpaceX's Dragon: America's Next Generation Spacecraft",
'Liftoff',
"SpaceX's Dragon: America's Next Generation Spacecraft",
'Cutting-Edge SpaceX News',
'SpaceX',
'Space Race 2.0',
'SpaceX and Tesla Motors Engineer Elon Musk',
'Elon Musk',
'Summary and Analysis of Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future',
'SpaceX from the Ground Up'
'SpaceX and Tesla Motors Engineer Elon Musk',
'Elon Musk'
]
2023-06-28T08:59:55.818Z response GET api.nasa.gov https://api.nasa.gov/planetary/apod true 200 OK application/json
The NASA APoD for today is at: https://apod.nasa.gov/apod/image/2306/M24_2023grapod1024.jpg

Done.
4 changes: 2 additions & 2 deletions docs/ts/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const example = {
const resource = { name: 'Jupiter', position: 5 };
const handleData = (data: JsonObject) =>
console.log('New planet:', data);
fetchJson.post('https://mockbin.org/request', resource)
fetchJson.post('https://centerkey.com/rest/', resource)
.then(handleData)
.catch(console.error);

Expand All @@ -57,7 +57,7 @@ const example = {
// Fetch me some tea
const handleData = (data: FetchJsonAltResponse) =>
console.log(data.bodyText);
fetchJson.get('https://centerkey.com/status/418/').then(handleData);
fetchJson.get('https://centerkey.com/rest/status/418/').then(handleData);

},

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@
},
"devDependencies": {
"@fortawesome/fontawesome-free": "~6.4",
"@types/node": "~20.6",
"@typescript-eslint/eslint-plugin": "~6.7",
"@typescript-eslint/parser": "~6.7",
"@types/node": "~20.8",
"@typescript-eslint/eslint-plugin": "~6.9",
"@typescript-eslint/parser": "~6.9",
"add-dist-header": "~1.3",
"assert-deep-strict-equal": "~1.1",
"copy-file-util": "~1.1",
"copy-folder-util": "~1.1",
"dna-engine": "~3.0",
"eslint": "~8.50",
"eslint": "~8.53",
"esm-to-plain-js": "~1.1",
"http-server": "~14.1",
"jsdom": "~22.1",
"jshint": "~2.13",
"mocha": "~10.2",
"puppeteer": "~21.3",
"puppeteer": "~21.5",
"puppeteer-browser-ready": "~1.3",
"replacer-util": "~1.2",
"rimraf": "~5.0",
Expand Down
Loading

0 comments on commit d24f441

Please sign in to comment.