Code Monkey home page Code Monkey logo

api-test's Introduction

API-TEST

AJAX

getList

axios({
  method: 'get',
  url: '%{origin}%/api/ajax/user/getList',
  params: {
    name: '',
    age: '',
    hobby: ''
  }
})
{
  "code": 200,
  "data": [
    {
      "id": "4ef33d1747a74678967b12537e5900bd",
      "name": "蔡徐坤",
      "age": 24,
      "hobby": "唱、跳、Rap、篮球",
      "createdTime": 1673214081611,
      "updatedTime": 1673214081611
    },
    {
      "id": "0cd22700f63a42e18d5829766d60bcb2",
      "name": "张三",
      "age": 23,
      "hobby": "太极",
      "createdTime": 1673214096222,
      "updatedTime": 1673220593209
    },
    {
      "id": "08c3e4e7ef6f4845aefac8dba71ed5f8",
      "name": "李四",
      "age": 24,
      "hobby": "足球",
      "createdTime": 1673214116240,
      "updatedTime": 1673214116240
    }
  ]
}

getUser

axios({
  method: 'get',
  url: '%{origin}%/api/ajax/user/getUser',
  params: {
    id: '0cd22700f63a42e18d5829766d60bcb2'
  }
})
{
  "code": 200,
  "data": {
    "id": "0cd22700f63a42e18d5829766d60bcb2",
    "name": "张三",
    "age": 23,
    "hobby": "太极",
    "createdTime": 1673214096222,
    "updatedTime": 1673220593209
  }
}

searchList

axios({
  method: 'get',
  url: '%{origin}%/api/ajax/user/searchList',
  params: {
    value: '球'
  }
})
{
  "code": 200,
  "data": [
    {
      "id": "4ef33d1747a74678967b12537e5900bd",
      "name": "蔡徐坤",
      "age": 24,
      "hobby": "唱、跳、Rap、篮球",
      "createdTime": 1673214081611,
      "updatedTime": 1673214081611
    },
    {
      "id": "08c3e4e7ef6f4845aefac8dba71ed5f8",
      "name": "李四",
      "age": 24,
      "hobby": "足球",
      "createdTime": 1673214116240,
      "updatedTime": 1673214116240
    }
  ]
}

addUser

axios({
  method: 'post',
  url: '%{origin}%/api/ajax/user/addUser',
  data: {
    name: '赵四',
    age: 51,
    hobby: '跳舞'
  }
})
{
  "code": 200,
  "data": {
    "id": "355b003b71c84fe7b6fde7435b2f9b3b",
    "name": "赵四",
    "age": 51,
    "hobby": "跳舞",
    "createdTime": 1673224873181,
    "updatedTime": 1673224873181
  }
}

updateUser

axios({
  method: 'put',
  url: '%{origin}%/api/ajax/user/updateUser',
  data: {
    id: '0cd22700f63a42e18d5829766d60bcb2',
    hobby: '唱歌'
  }
})
{
  "code": 200,
  "data": {
    "id": "0cd22700f63a42e18d5829766d60bcb2",
    "name": "张三",
    "age": 23,
    "hobby": "唱歌",
    "createdTime": 1673214096222,
    "updatedTime": 1673220593209
  }
}

deleteUser

axios({
  method: 'delete',
  url: '%{origin}%/api/ajax/user/deleteUser',
  data: {
    id: '0cd22700f63a42e18d5829766d60bcb2'
  }
})
{
  "code": 200,
  "data": null
}

JSONP

getList

<script>
  function fn(data) {
    console.log(data)
  }
</script>
<script src="%{origin}%/api/ajax/user/getList?name=张三&callback=fn"></script>

getUser

<script>
  function fn(data) {
    console.log(data)
  }
</script>
<script src="%{origin}%/api/ajax/user/getUser?id=0cd22700f63a42e18d5829766d60bcb2&callback=fn"></script>

searchList

<script>
  function fn(data) {
    console.log(data)
  }
</script>
<script src="%{origin}%/api/ajax/user/searchList?value=test&callback=fn"></script>

PROXY

跨域代理

axios({
  url: '%{origin}%/proxy/%{origin}%/api/ajax/user/getList',
  method: 'get',
  params: {
    name: '坤',
    hobby: '球'
  }
})
{
  "code": 200,
  "data": [
    {
      "id": "4ef33d1747a74678967b12537e5900bd",
      "name": "蔡徐坤",
      "age": 24,
      "hobby": "唱、跳、Rap、篮球",
      "createdTime": 1673214081611,
      "updatedTime": 1673214081611
    }
  ]
}

api-test's People

Contributors

iuukai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.