GuidesAPI Reference
API Reference

exportMocks(mockIds, groupIds, prettify)

Exports selected mocks and groups.
By default this function outputs a minified JSON response, If you want a more readable output you can specify the prettify argument to true.

import Mimic from 'mimic';

Mimic.exportMocks(['mock-id'], ['group-id']); // Default Output
Mimic.exportMocks(['mock-id'], ['group-id'], true); // Prettified Output

Output

{"version":"2.0.0","mocks":[{"id":"4034db5e-34e1-401c-b023-49ec55cf3028","active":true,"method":"GET","url":"http://uinames.com/api/?amount=2&region=russia","headers":{"accept":"*/*"},"response":{"delay":659,"status":500,"headers":{"pragma":"no-cache","content-type":"application/json; charset=utf-8","cache-control":"no-cache","expires":-1},"body":{"mocked":true}},"origin":"http://localhost:8080"},{"id":"a4f91a92-fa12-498d-9481-1da3e0458cf0","active":true,"method":"GET","url":"http://jsonplaceholder.typicode.com/posts/4","headers":{},"response":{"status":200,"delay":106,"headers":{"content-type":"application/json"},"body":"{ \"mocked\": true }"},"origin":null,"groupId":"743a78b5-cf0c-4240-bea7-0cc926159876"},{"id":"6c5af819-ab56-4dad-aace-fbac9fb6e676","active":true,"method":"GET","url":"http://jsonplaceholder.typicode.com/posts/3","headers":{},"params":"","response":{"status":200,"delay":135,"headers":{"pragma":"no-cache","content-type":"application/json; charset=utf-8","cache-control":"public, max-age=14400","expires":"Sun, 19 Mar 2017 23:35:47 GMT"},"body":"{ \"mocked\": true }"},"origin":"http://localhost:8080","groupId":"743a78b5-cf0c-4240-bea7-0cc926159876"}],"groups":[{"id":"743a78b5-cf0c-4240-bea7-0cc926159876","name":"My Group","active":true}]}

Prettified Output

{
  "version": "2.0.0",
  "mocks": [
    {
      "id": "4034db5e-34e1-401c-b023-49ec55cf3028",
      "active": true,
      "method": "GET",
      "url": "http://uinames.com/api/?amount=2&region=russia",
      "headers": {
        "accept": "*/*"
      },
      "response": {
        "delay": 659,
        "status": 500,
        "headers": {
          "pragma": "no-cache",
          "content-type": "application/json; charset=utf-8",
          "cache-control": "no-cache",
          "expires": -1
        },
        "body": {
          "mocked": true
        }
      },
      "origin": "http://localhost:8080"
    },
    {
      "id": "a4f91a92-fa12-498d-9481-1da3e0458cf0",
      "active": true,
      "method": "GET",
      "url": "http://jsonplaceholder.typicode.com/posts/4",
      "headers": {},
      "response": {
        "status": 200,
        "delay": 106,
        "headers": {
          "content-type": "application/json"
        },
        "body": "{ \"mocked\": true }"
      },
      "origin": null,
      "groupId": "743a78b5-cf0c-4240-bea7-0cc926159876"
    },
    {
      "id": "6c5af819-ab56-4dad-aace-fbac9fb6e676",
      "active": true,
      "method": "GET",
      "url": "http://jsonplaceholder.typicode.com/posts/3",
      "headers": {},
      "params": "",
      "response": {
        "status": 200,
        "delay": 135,
        "headers": {
          "pragma": "no-cache",
          "content-type": "application/json; charset=utf-8",
          "cache-control": "public, max-age=14400",
          "expires": "Sun, 19 Mar 2017 23:35:47 GMT"
        },
        "body": "{ \"mocked\": true }"
      },
      "origin": "http://localhost:8080",
      "groupId": "743a78b5-cf0c-4240-bea7-0cc926159876"
    }
  ],
  "groups": [
    {
      "id": "743a78b5-cf0c-4240-bea7-0cc926159876",
      "name": "My Group",
      "active": true
    }
  ]
}