Content-Type data format

In response to requests from many users, different data format support has been added. It’s as simple as adding a Content-Type field to the request header to tell FastMock what format you want to return:

For example, when using Axios as an Ajax library

axios.defaults.headers.common['Content-Type'] = 'application/json; charset=UTF-8';

When you enter data, you still enter JSON data, and you can still simulate everything using MockJS as normal

Data types that are now supported

The data type The content-type value
json application/json
xml text/xml

Use the sample

School rules

{data: [{name: 'lisi'},{name: 'lisi'}]}

Postman request json

Postman request XML