forked from jackyzha0/quartz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📇👋 -> Initialising API calls for #3
- Loading branch information
1 parent
8b5cc69
commit d1dc42d
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
dappyaccount.json | ||
dappykeys.json | ||
userkeys.json | ||
useraccount.json | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
|
||
#Hardhat files | ||
cache | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var axios_1 = require("axios"); | ||
var url = 'https://jsonplaceholder.typicode.com/todos/1'; | ||
axios_1["default"].get(url).then(function (response) { | ||
// Called when we get a response from the API | ||
// response.data properties: `id`, `title`, `completed` | ||
var todo = response.data; | ||
var id = todo.id; | ||
var title = todo.title; | ||
var completed = todo.completed; | ||
logTodo(id, title, completed); | ||
}); | ||
var logTodo = function (id, title, completed) { | ||
console.log("\n The Todo with ID: ".concat(id, "\n Has a title of: ").concat(title, "\n Is it finished? ").concat(completed, "\n ")); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import axios from 'axios'; | ||
|
||
const url = 'https://jsonplaceholder.typicode.com/todos/1'; | ||
|
||
interface Todo { | ||
id: number; // Id of the note (not userId, as userId is ignored) | ||
title: string; | ||
completed: boolean; | ||
} | ||
|
||
axios.get(url).then(response => { | ||
// Called when we get a response from the API | ||
// response.data properties: `id`, `title`, `completed` | ||
const todo = response.data as Todo; | ||
const id = todo.id; | ||
const title = todo.title; | ||
const completed = todo.completed; | ||
|
||
logTodo(id, title, completed); | ||
}); | ||
|
||
const logTodo = (id: number, title: string, completed: boolean) => { | ||
console.log(` | ||
The Todo with ID: ${id} | ||
Has a title of: ${title} | ||
Is it finished? ${completed} | ||
`); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "fetchjson", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"axios": "^0.25.0" | ||
} | ||
} |