创立一个文件夹
装置一个 申请工具 我用的 reqwest,还须要xhr2

代码如下

const reqwest = require("reqwest");const path = require("path");const fs = require("fs");(async function () {    //获取access_toekn 30天无效    let access_token = await get_access_token()     //读取身份证,转为base64    var data = fs.readFileSync(`./sfz/1.jpg`);    data = data.toString('base64');    //间接申请,相干api+access_token    //参数两个必传项,    //image: base64图片,    //id_card_side: 'front或back' 正反面的意思        let res = await reqwest({            url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=' + access_token,            contentType: 'application/x-www-form-urlencoded',            method: "post",            data: {                image: data,                id_card_side: 'front'            }        })        console.log(res)//这里就是后果了})()//获取access_token 但写的办法async function get_access_token() {    let res = await reqwest({        method: 'post',        type: 'json',        url: 'https://aip.baidubce.com/oauth/2.0/token',        data: {            'grant_type': 'client_credentials',            'client_id': 'appid',//百度提供            'client_secret': 'appkey'//百度提供        }    })    return res.access_token}