Code Monkey home page Code Monkey logo

Comments (6)

07akioni avatar 07akioni commented on May 22, 2024

欢迎 PR,我对 uniapp 不太熟

from lyla.

chengazhen avatar chengazhen commented on May 22, 2024

关于基于 lylajs 实现会有以下问题。请教一下是否有解决思路。
image
关于这两段代码,对于 if (method === 'GET' && body) { } 校验代码段是不是应该放在 adapter 里面自行决定校验?

举个例子,在小程序里面不管是get和post传参都是放在data对象(相当于浏览器端的post 请求的body,可以理解为小程序里面不管什么请求参数都是放在body里面的)。

问题(只在get请求里面存在)

  1. 在这个get方法里面如果使用query,那么就会遇到小程序里面没有 urlSearchParams 字段的报错。
export function getRepoList(data: { status: string }) {
  return lyla<Item>({
    method: 'get',
    url: '/pet/findByStatus',
    // body: data
    query: data
  })
}

image

  1. 如果在get方法使用 json 或者 body 就会遇到下面的错误。因为 options.json 最终会被合并到了 body 里面。body 和 json 对于get 请求是互斥的。
export function getRepoList(data: { status: string }) {
  return lyla<Item>({
    method: 'get',
    url: '/pet/findByStatus',
    body: data
    // query: data
  })
}

image

from lyla.

chengazhen avatar chengazhen commented on May 22, 2024

这个是我写的一个仓库,里面有复现问题的demo,需要在小程序的环境下可以复现对应的问题

from lyla.

07akioni avatar 07akioni commented on May 22, 2024

我能理解你说的问题,可以加一个选项来处理

from lyla.

07akioni avatar 07akioni commented on May 22, 2024

发布了 1.11.0,增加了一个选项叫 allowGetBody,设为 true 的话可以把 get + body 的组合发出去

from lyla.

07akioni avatar 07akioni commented on May 22, 2024

uniapp 的想要你可以 copy 一个 wx 的包改吧改吧提个 PR

from lyla.

Related Issues (8)

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.