Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ exports.config = {
```

The following is an example that uses the [jsonplaceholder](https://jsonplaceholder.typicode.com/) to fetch a list of
User IDs for my app. It uses the `json` plugin.
User IDs for my app. It uses the [JSON Plugin](../scully/routerPlugins/jsonRoutePlugin.ts) which is already part of Scully.

```javascript
// scully.config.js
Expand All @@ -113,6 +113,26 @@ second is `property`. The JSON plugin will pluck the provided property name fro
means that the array returned by the jsonplaceholder api will each have an `id` property. So instead of returning a list
users, it will return a list of userIds.

The JSON Plugin will optionally accept also a header configuration where you can set specific header that you may have to sent when requesting an API:

```javascript
// scully.config.js
exports.config = {
routes: {
"/todos/:todoId": {
"type": "json",
"todoId": {
"url": "https://my-api.com/todos",
"property": "id",
"headers": {
"API-KEY": "0123456789"
}
}
}
}
};
```

### <a name="router-plugin-configure"></a> Router Plugin Examples
For those looking to build router plugins for their app, here are links to the built-in __router plugins__ in Scully:
- [JSON Plugin](../scully/routerPlugins/jsonRoutePlugin.ts)
Expand Down
Loading