I have created a custom machine in treeline.io that searches twitter and returns an array of objects that i would like to insert into my database as Models.
Here is the format of the returned array:
[
{
"postText": "RT @TheJWittz: MEWTWOOOOOOOOO http://t.co/ZzZsiGIDE4",
"postID": "583388726883180500",
"postStatus": "new",
"postDate": "Wed Apr 01 22:01:25 +0000 2015",
"postScheduleDate": "",
"postUserImageURL": "http://ift.tt/19HFbSR",
"postUserRealName": "",
"postUserName": "",
"postUpdateUser": "",
"postType": "twitter",
"postStatusDate": "2015-04-01T22:01:50.745Z",
"postHasImage": true,
"postImagePreviewURL": "http://ift.tt/19HFcq2",
"postImageURL": "http://ift.tt/1CQTW18",
"postHasVideo": false,
"postVideoPreviewURL": "",
"postVideoURL": ""
}
]
I am trying to use the "each" machine and telling it to pass each item within the array to my "Create Post" machine which should create a new Post. However it's throwing a load of errors when i try to do this, i'm guessing it's having issues either understanding the object it's been given, or that some of the values don't match. Either way i'm a little stuck.
Here is what i get in the console when i load the Route:
error: Sending 500 ("Server Error") response:
Error: `create_post` machine encountered 17 error(s) while validating runtime input values.
at /Users/garethjeanne/Documents/HTL2/htl-treeline/node_modules/machine/lib/Machine.prototype.exec.js:53:19
at Machine_prototype_exec [as exec] (/Users/garethjeanne/Documents/HTL2/htl-treeline/node_modules/machine/lib/Machine.prototype.exec.js:61:9)
at /Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/machines/map.js:79:29
at /Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:249:17
at /Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:125:13
at Array.forEach (native)
at _each (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:46:24)
at async.each (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:124:9)
at _asyncMap (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:248:13)
at /Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/async/lib/async.js:219:23
at Object.module.exports.fn (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/machines/map.js:76:5)
at _runMachine (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/machine/lib/Machine.prototype.exec.js:281:17)
at afterCacheLookup (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/machine/lib/Machine.prototype.exec.js:288:7)
at _cacheLookup (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/machine/lib/Machine.prototype.exec.js:160:25)
at Machine_prototype_exec [as exec] (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/machines/69aac477-d97c-4280-a225-39a345fdbd3f_0.3.0/node_modules/machinepack-loops/node_modules/machine/lib/Machine.prototype.exec.js:211:5)
at Object.sails.machines.c1191290-9d8f-4ce4-a84e-74621c88a99d_0.0.1.get_minus_search_minus_term.setEnvironment.exec.success (/Users/garethjeanne/Documents/HTL2/htl-treeline/api/controllers/FetchController.js:35:28) { [Error: `create_post` machine encountered 17 error(s) while validating runtime input values.]
code: 'E_MACHINE_RUNTIME_VALIDATION',
machine: 'create_post',
reason: '`create_post` machine encountered 17 error(s) while validating runtime input values.',
status: 400,
errors:
[ { [Error: 2 error(s) validating value:
[ { [Error: An invalid value was specified:
{ postText: '@RussyViC get the badger hawk',
postID: '583424534688243700',
postStatus: 'new',
postDate: 'Thu Apr 02 00:23:43 +0000 2015',
postScheduleDate: '',
postUserImageURL: 'http://ift.tt/19HFeOp',
postUserRealName: '',
postUserName: '',
postUpdateUser: '',
postType: 'twitter',
postStatusDate: '2015-04-02T00:24:11.826Z',
postHasImage: false,
postImagePreviewURL: '',
postImageURL: '',
postHasVideo: false,
postVideoPreviewURL: '',
postVideoURL: '' }
This doesn't match the specified type:
'string'] code: 'E_INVALID_TYPE' },
{ [Error: An invalid value was specified:
{ postText: '@RussyViC get the badger hawk',
postID: '583424534688243700',
postStatus: 'new',
postDate: 'Thu Apr 02 00:23:43 +0000 2015',
postScheduleDate: '',
postUserImageURL: 'http://ift.tt/19HFeOp',
postUserRealName: '',
postUserName: '',
postUpdateUser: '',
postType: 'twitter',
postStatusDate: '2015-04-02T00:24:11.826Z',
postHasImage: false,
postImagePreviewURL: '',
postImageURL: '',
postHasVideo: false,
postVideoPreviewURL: '',
postVideoURL: '' }
This cannot be coerced into the specified type:
'string'] code: 'E_COERCION' } ]] code: 'E_INVALID_TYPE', minor: false, errors: [Object] },
{ [Error: `postID` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postID',
reason: '`postID` is a required input- but it was not defined.' },
{ [Error: `postStatus` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postStatus',
reason: '`postStatus` is a required input- but it was not defined.' },
{ [Error: `postDate` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postDate',
reason: '`postDate` is a required input- but it was not defined.' },
{ [Error: `postUserImageURL` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postUserImageURL',
reason: '`postUserImageURL` is a required input- but it was not defined.' },
{ [Error: `PostUserName` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'PostUserName',
reason: '`PostUserName` is a required input- but it was not defined.' },
{ [Error: `PostUserRealName` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'PostUserRealName',
reason: '`PostUserRealName` is a required input- but it was not defined.' },
{ [Error: `postType` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postType',
reason: '`postType` is a required input- but it was not defined.' },
{ [Error: `postStatusDate` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postStatusDate',
reason: '`postStatusDate` is a required input- but it was not defined.' },
{ [Error: `postHasImage` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postHasImage',
reason: '`postHasImage` is a required input- but it was not defined.' },
{ [Error: `postImagePreviewURL` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postImagePreviewURL',
reason: '`postImagePreviewURL` is a required input- but it was not defined.' },
{ [Error: `postImageURL` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postImageURL',
reason: '`postImageURL` is a required input- but it was not defined.' },
{ [Error: `postScheduleDate` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postScheduleDate',
reason: '`postScheduleDate` is a required input- but it was not defined.' },
{ [Error: `postUpdateUser` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postUpdateUser',
reason: '`postUpdateUser` is a required input- but it was not defined.' },
{ [Error: `postHasVideo` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postHasVideo',
reason: '`postHasVideo` is a required input- but it was not defined.' },
{ [Error: `postVideoPreviewURL` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postVideoPreviewURL',
reason: '`postVideoPreviewURL` is a required input- but it was not defined.' },
{ [Error: `postVideoURL` is a required input- but it was not defined.]
code: 'E_INPUT_REQUIRED',
input: 'postVideoURL',
reason: '`postVideoURL` is a required input- but it was not defined.' } ] }
Aucun commentaire:
Enregistrer un commentaire