GithubHelp home page GithubHelp logo

typescript描述文件问题 about umi-request HOT 11 CLOSED

umijs avatar umijs commented on August 22, 2024
typescript描述文件问题

from umi-request.

Comments (11)

yesmeck avatar yesmeck commented on August 22, 2024

你是实际碰到了问题?还是只是心里有疑问?

from umi-request.

bshy522 avatar bshy522 commented on August 22, 2024

你是实际碰到了问题?还是只是心里有疑问?

实际遇到问题

from umi-request.

yesmeck avatar yesmeck commented on August 22, 2024

直接说碰到的问题

from umi-request.

bshy522 avatar bshy522 commented on August 22, 2024

直接说碰到的问题

就是ts里面 会报错啊,说这个地方不能收这个类型 我也是刚开始用ts,从错误看结合这个描述文件看,应该是这里 handler函数的返回定义的不对。代码里面是支持返回一个promise的

from umi-request.

bshy522 avatar bshy522 commented on August 22, 2024

response = response.then(res => handler(res, options));

from umi-request.

yesmeck avatar yesmeck commented on August 22, 2024

handler 现在不支持返回 promise。

#28

from umi-request.

bshy522 avatar bshy522 commented on August 22, 2024

handler 现在不支持返回 promise。

#28

额。。我看上面那个逻辑是支持的吧。。

from umi-request.

yesmeck avatar yesmeck commented on August 22, 2024

那是还没合并的代码。

from umi-request.

bshy522 avatar bshy522 commented on August 22, 2024

那是还没合并的代码。

好的,多谢。

期待发新版

from umi-request.

clock157 avatar clock157 commented on August 22, 2024

@bshy522 那个 mr 有问题一直没合,你能说下你的具体场景和需求吗?有兴趣重新提 mr 吗。

from umi-request.

eightHundreds avatar eightHundreds commented on August 22, 2024

文档中的代码段

/**
* 5. For the status code is actually 200 errors
*/
request.interceptors.response.use(async (response) => {
  const data = await response.clone().json();
  if(data && data.NOT_LOGIN) {
    location.href = 'login url';
  }
  return response;
})

在ts不支持,拦截方法返回的是Promise

from umi-request.

Related Issues (20)

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.