feat: 接口名统一增加API后缀
This commit is contained in:
parent
1b7ae81550
commit
6fce781794
@ -10,10 +10,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="mt-6">
|
<view class="mt-6">
|
||||||
<!-- http://localhost:9000/#/pages/index/request -->
|
<!-- http://localhost:9000/#/pages/index/request -->
|
||||||
<button @click="testRequest" class="my-4">测试 GET 请求</button>
|
<button @click="getFoo" class="my-4">测试 GET 请求</button>
|
||||||
<view class="text-xl">请求数据如下</view>
|
<view class="text-xl">请求数据如下</view>
|
||||||
<view class="text-green h-10">{{ JSON.stringify(data) }}</view>
|
<view class="text-green h-10">{{ JSON.stringify(data) }}</view>
|
||||||
<button @click="testRequest2" class="my-4">测试 POST 请求</button>
|
<button @click="postFoo" class="my-4">测试 POST 请求</button>
|
||||||
<view class="text-xl">请求数据如下</view>
|
<view class="text-xl">请求数据如下</view>
|
||||||
<view class="text-green h-10">{{ JSON.stringify(data2) }}</view>
|
<view class="text-green h-10">{{ JSON.stringify(data2) }}</view>
|
||||||
|
|
||||||
@ -32,24 +32,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getFoo, postFoo, IFooItem } from '@/service/foo'
|
import { getFooAPI, postFooAPI, IFooItem } from '@/service/foo'
|
||||||
|
|
||||||
const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX')
|
const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX')
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
testRequest()
|
getFoo()
|
||||||
testRequest2()
|
postFoo()
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = ref<IFooItem>()
|
const data = ref<IFooItem>()
|
||||||
const testRequest = async () => {
|
const getFoo = async () => {
|
||||||
const res = await getFoo('菲鸽')
|
const res = await getFooAPI('菲鸽')
|
||||||
data.value = res.result
|
data.value = res.result
|
||||||
}
|
}
|
||||||
|
|
||||||
const data2 = ref<IFooItem>()
|
const data2 = ref<IFooItem>()
|
||||||
const testRequest2 = async () => {
|
const postFoo = async () => {
|
||||||
const res = await postFoo('菲鸽2')
|
const res = await postFooAPI('菲鸽2')
|
||||||
data2.value = res.result
|
data2.value = res.result
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,7 +4,7 @@ import type { IFooItem } from './foo.d'
|
|||||||
export { IFooItem }
|
export { IFooItem }
|
||||||
|
|
||||||
/** get 请求 */
|
/** get 请求 */
|
||||||
export const getFoo = (name: string) => {
|
export const getFooAPI = (name: string) => {
|
||||||
return http<IFooItem>({
|
return http<IFooItem>({
|
||||||
url: `/foo`,
|
url: `/foo`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -13,7 +13,7 @@ export const getFoo = (name: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** get 请求 */
|
/** get 请求 */
|
||||||
export const postFoo = (name: string) => {
|
export const postFooAPI = (name: string) => {
|
||||||
return http<IFooItem>({
|
return http<IFooItem>({
|
||||||
url: `/foo`,
|
url: `/foo`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user