Giter VIP home page Giter VIP logo

Comments (2)

codebear228 avatar codebear228 commented on August 29, 2024

错误原因,localStorage.setItem是同步的,造成错误的原因是umi-request的request在获取到token之前就初始化了,所以此时header里的token为null;解决方法,在获取到token之后使用extendOptions来增加token,确保再发起请求一定会带上token.

from pet-flask-refactor.

codebear228 avatar codebear228 commented on August 29, 2024

使用extendOptions只在第一次登陆后有效,这时token储存在localStorage就失去了意义,刷新浏览器,extendOptions丢失,依旧没有带上token;解决方法,在request.js中重写request重新暴露一个_request方法,每次request都带上token。

from pet-flask-refactor.

Related Issues (7)

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.