GuidesAPI Reference
API Reference

import(jsonString)

Import mocks to Mimic. This function accepts a json string of exported output from Mimic.

import Mimic from 'mimic';

Mimic.import(`{
  "version": "2.0.0",
  "mocks": [
    {
      "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
    }
  ]
}`)
.then(function (status) {
  console.log({ success: status.success, error: status.error });
});