Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
let url = "https://jsonplaceholder.typicode.com/todos/1";
//fetch api
fetch(url)
.then((response) => response.json())
.then((json) => console.log(json))
.catch((err) => console.log("error"));
//ecma2017,async await 简化fetch
async function getUser(url) {
try {
const response = await fetch(url);
const result = await response.json();
console.log(result);
} catch (error) {
console.log("error");
}
}
getUser(url);
npm i axios :全部安装
npm i axios -S:安装生产依赖
npm i axios -D:安装开发依赖
npm ui axios:删除包
//核心模块
const http = require("http");
console.log(http.Agent);
//文件模块
const site = require("./outside.js");
console.log(site.getSite());
//第三方模块: npm安装的
let site = "php中文网";
let getSite = function () {
return site + " (php.cn)";
};
exports.site = site;
exports.getSite = getSite;