轻量级HTTP请求库:request-my

做项目的初衷: 大家经常用http请求,以前用的比较多的是jq的ajax,现在用的多的是axios,我就是想写一个比较简单的http请求工具,平时html也能使用,就是简单使用及测试用的。希望大家多多使用。

轻量级HTTP请求库:request-my

安装

使用 npm:

$ npm install request-my --save

例子

UsageES2015

import {api} from 'request-my';

api.ajax({
    url:'xxx:3000/post',
    type:'post',
    data:{
      name:'shibin'
    },
    success:function(res){
      console.log(res)
    },
    error:function(err){
      console.log(err);
    }
})

浏览器使用The dist folder contains index.js.

<script type="text/javascript" src="./dist/request-my.min.js"></script>
<script>
api.ajax({
    url:'xxx:3000/post',
    type:'post',
    data:{
      name:'shibin'
    },
    success:function(res){
      console.log(res)
    },
    error:function(err){
      console.log(err);
    }
})
</script>

更多的前端视频也会继续为大家更新,有需要前端视频教程的伙伴,可以留言:HTML,我会发大家全套的视频教程。

发布了699 篇原创文章 · 获赞 183 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/chen801090/article/details/105538607
今日推荐