@caoke90/service

数据接口函数

Usage no npm install needed!

<script type="module">
  import caoke90Service from 'https://cdn.skypack.dev/@caoke90/service';
</script>

README

本地对象存储

const Bos=require('@caoke90/bos')

const bos=new Bos(__dirname+'/localDb/');
const axios =require('axios');


async function getCache(key,value,option) {
    let res;
    if(key==='fundcode_search'){
        res=await bos.getData(key)
        if(!res){
            const resp=await axios.get('http://fund.eastmoney.com/js/fundcode_search.js')
            console.log(resp.status)
            if(resp.status===200){
                res=resp.data.replace(/^var r = ([\d\D]+);$/,'$1');
                await bos.setData(key,res)
            }
        }
    }
    return res;
}
//注册
async function init(name,data) {
    const list=await getCache('fundcode_search')
   console.log(list)
}

init();

切换淘宝源

npm config set registry https://registry.npmjs.org/

登录

npm login

发布

npm publish --access=public