GithubHelp home page GithubHelp logo

我也来出题 about fe-interview HOT 4 OPEN

lgwebdream avatar lgwebdream commented on May 1, 2024 6
我也来出题

from fe-interview.

Comments (4)

magicyangmei avatar magicyangmei commented on May 1, 2024

分享我在工作中遇到的一道题,首先我请求了一个a接口,返回结果作为下一个接口b的参数,b接口收到参数后发起请求,但是不回马上返回结果,需要定时查询,直到查询返回结果为止,如果使用定时器如何让两个请求同步执行,出现定时器执行越来越快的问题,如何解决?

from fe-interview.

reggiolee avatar reggiolee commented on May 1, 2024

分享我在工作中遇到的一道题,首先我请求了一个a接口,返回结果作为下一个接口b的参数,b接口收到参数后发起请求,但是不回马上返回结果,需要定时查询,直到查询返回结果为止,如果使用定时器如何让两个请求同步执行,出现定时器执行越来越快的问题,如何解决?

如果b接口的参数依赖于a接口的返回,在不改变后端接口逻辑的情况下,不存在能请求同步的情况。而b接口不马上返回结果,可前端轮询或者后端推送的方式,这个看具体项目实践而定。如果非要ab接口请求同步,则需要修改接口逻辑,如将b接口拆成c、d接口,c接口传递的是与a接口返回结果无关的参数,然后后端基于这些参数先进行一部分工作,等到a接口返回再发送d接口,然后再补充相关参数。另外,如果需要a接口的返回作为参数,那么b接口能否修改,因为后端自己调用会更快,哪怕不同组件模块之间,内网调用也快于外网调用

from fe-interview.

ben-Run avatar ben-Run commented on May 1, 2024

@magicyangmei
const res = await a
await b(res)
这样不行吗?

from fe-interview.

l55776 avatar l55776 commented on May 1, 2024

前端面试库可以搜索 前端MST宝库  就有了

from fe-interview.

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.