In the long-term service process, we often encounter the following feedback from users who come to consult with us: Consultants is a front end staff, in the process of project development needs with the back-end for docking, encounter have not finished the back-end data output, he had to write static simulation data, in case of large projects, lengthy, complex code, a variety of data types including IP, pictures, address, function, etc., in a very short project cycle and acceptance of time, Manually modifying the simulation data is not practical at all.

EoLinker offers the best solution to this problem: the Mock API.

With the Mock API, people at the front and back end need only define interface documents to start working in parallel; Interface coupling between back ends and unprepared dependency interfaces in testing can also be Mock out without team parity. In this way, the earlier the development of self-testing, the time to find and repair defects in advance, but also effectively ensure the quality and progress of the entire product.

EoLinker provides two ways to Mock an API, basic Mock and advanced Mock. How to use eoLinker Mock? What is the difference between a basic Mock and an advanced Mock?

In eoLinker, basic Mocks, also known as simple Mocks, provide the following capabilities: Support HTTP and HTTPS 2. Support RESTful API 3. Support verification of request mode (free version is enabled by default. Advanced Mocks have the same functionality as basic Mocks. Advanced Mocks have the same functionality as basic Mocks. Create mock data based on mockJS rules and customize JS functions. Create mock data based on mockJS rules and customize JS functions. Function points 3, 6, and 8 need to be used in professional AMS. Let’s take a quick look at three important feature points.

1. Support setting generation rules for return results, support MockJS:

Mock.js is surprisingly easy to Mock backend data with because it intercepts and simulates Ajax requests:

Combined with the above scenario, eoLinker solves all of the following problems by supporting MockJS.

1. The documentation is not defined in advance, and the development process may be verbally described by the backend personnel, but the actual data returned is not the same. The eoLinker Advanced Mock itself standardizing this behavior, and efficient collaboration is not a problem.

3. You want to restore as much real data as possible without writing more code or manually modifying simulated data. Directly simulate background data return, get twice the result with half the effort.

4, do not worry about such as IP, random number, pictures, addresses and other special formats of multiple collection, rich format support to save a lot of time.

EoLinker’s MOCK also supports complex data types such as custom functions and regees, making it easy to extend more data types. Because of this, eoLinker MockAPI supports MockJS, which solves the problem of data emulation in front and back end development and greatly improves development productivity.

2. Verify the request parameters:

This is an advanced version of the function, eoLinker takes into account the development process, there are many back-end interface parameters will be checked to determine which interface parameters are mandatory and which interface parameters are not mandatory. However, front-end development calls Mock interface. From the perspective of assistance, MockAPI simulates the backend interface to return parameters for collaborative front-end development, so the parameter verification function is very necessary to simulate the most real back-end interface and better assist front-end development. EoLinker supports verification of request parameters to determine whether these interface parameters are required to be transmitted. In this way, no parameter will be missed, effectively avoiding redundant work.

3, support each request to generate random return results:

This is also a feature in the advanced version, and eoLinker recognizes that the ability to generate random returns is a necessary feature because the interface returns different values of parameters each time, so random generation can make simulated returns more realistic.

Next comes the advanced Mock actual tutorial. 1. Edit Mock data to go to the Interface edit page. Click the advanced Mock TAB to go to the Mock Settings page:

Note: The completion of Mock depends on the return parameters in the interface document. If you go to the Mock Settings page and find no fields that can be set, please return to the basic information TAB to improve the return information of the interface. MockAPI supports the Mockjs syntax, which can be learned at http://Mockjs.com/; Use the following steps: 1. Return parameters to fill in the key value pair, if there is a hierarchy result, please use two English right arrow >> or :: to indicate the hierarchy:

Split fill out the Mockjs sample. The red box part of the following figure is explained:

Name Indicates the field name of the list. Min-max corresponding list generation rule; String corresponds to the list attribute value. Use with @mock =, for example, @mock = ‘★’.

Write the Mock syntax above:

Note: The part in red box is to set the overall return result type, which supports two types (Object /array). The generated rules and attribute values also correspond to Mockjs syntax

2. Call MockAPI to enter the interface details page, click the Mock TAB at the top, and you can see the MockAPI request address in the Mock section below. Copy this address to access the MockAPI and obtain virtual data:

Follow wechat public account eoLinker for more API information and development tips!

Website: www.eolinker.com

Github source: github.com/eolinker