Promise
方北北
这个作者很懒,什么都没留下…
展开
-
pormise数据库操作例子
const mongoose = require('mongoose') mongoose.connect('mongodb://localhost/demo') const Schema = mongoose.Schema const userSchema = new Schema({ username: { type: String, required: true }...原创 2020-01-18 14:26:23 · 510 阅读 · 0 评论 -
Promise-then的链式调用
const fs = require('fs') function pReadFile(filePath){ return new Promise((resolve, reject) => { fs.readFile(filePath, (err, data) => { if (err) { reject(err) } else ...原创 2020-01-18 11:16:55 · 403 阅读 · 0 评论 -
Promise基本使用1
const fs = require('fs') const p1 = new Promise((resolve, reject) => { fs.readFile('../data/a.txt', (err, data) => { if (err) { reject(err) } else { resolve(data) } ...原创 2020-01-18 10:48:36 · 238 阅读 · 0 评论