File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,21 @@ const getMultipleItems = function (options) {
6666 * @param {String } itemId (required)
6767 */
6868const getSingleItem = function ( itemId ) {
69- if ( ! itemId ) throw new Error ( 'invalid_request_error -> Item ID is null or invalid' ) ;
70- const requestUrl = `${ urlObject . buildShoppingUrl ( this . options , 'GetSingleItem' ) } &${ stringifyUrl ( { 'ItemID' : itemId } ) } ` ;
71- return getRequest ( requestUrl ) . then ( ( data ) => {
72- return JSON . parse ( data ) ;
73- } , console . error // eslint-disable-line no-console
69+ if ( ! input || ( typeof input !== 'object' && typeof input !== 'string' ) )
70+ throw new Error ( 'invalid_request_error -> Invalid input' ) ;
71+ // To preserve backwards compatibility
72+ if ( typeof input === 'string' ) {
73+ input = { ItemID : input } ;
74+ }
75+ const requestUrl = `${ urlObject . buildShoppingUrl (
76+ this . options ,
77+ 'GetSingleItem'
78+ ) } &${ stringifyUrl ( input ) } `;
79+ return getRequest ( requestUrl ) . then (
80+ ( data ) => {
81+ return JSON . parse ( data ) ;
82+ } ,
83+ console . error // eslint-disable-line no-console
7484 ) ;
7585} ;
7686
You can’t perform that action at this time.
0 commit comments