Coder Social home page Coder Social logo

mock's Issues

关于json 请求的判断疑问

if (!view) {
  return this.body = data;
}
if (IS_JSON_RE.test(this.path)) {
  return this.body = data;
}

就是有点疑问, 如果我需要mock的是一个 json, 那么我准备的 mock 数据理论上就不应该有 __view. 那么直接在第一个判断就返回了.

如果我请求的 user.json 是一个页面, 那么就算我准备了一个__view 那么还是会渲染成 json.

那什么情况下, 我请求一个 json 的 mock, 我还会提供一个__view呢?

auto read mock data on ajax request

Need to meet the conditions:

  • ajax request
  • referer should be a mock url

GET /user/profile.json on /home?__scene=default page, should try to read /user/profile.json/default.js mock data file.

  • exists, return the mock data
  • not exists, return normal data

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.