-
-
Save netmilk/b52a329b79ef307cbf70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stash object will automatically cache all responses under key with their name, | |
# parse JSON body and parse headers | |
{before, after, stash} = require 'hooks' | |
before "Machines > Machine > Retrieve a Machine", (transaction) -> | |
newId = stash['Machines > Machines collection > Create a Machine'].response.body._id | |
# replace id taken from blueprint with id from stash | |
transaction.request.uri = transaction.request.uri.replace '52341870ed55224b15ff07ef', newId | |
transaction.fullPath = transaction.fullPath.replace '52341870ed55224b15ff07ef', newId | |
# or better with some patchUri helper on transaction object | |
{before, after, stash} = require 'hooks' | |
before "Machines > Machine > Retrieve a Machine", (transaction) -> | |
newId = stash['Machines > Machines collection > Create a Machine'].response.body._id | |
transaction.patchUri _id: newId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment