Page 1 of 3

mapping problem returning undefined

Posted: Wed Jul 23, 2014 6:52 pm
by Michael4771079

Hi,
I have a service that works in the test tab and in the app when checked in console, also no errors in console,
but returns undefined for some lablels,
I added
if(value === undefined){ return ''; } to the label marked in the screenshot and it returns nothing.at all
service is called on page show.
Can you see from the screenshots whats wrong?

Image

Image

Image

Image

Image

Image


mapping problem returning undefined

Posted: Wed Jul 23, 2014 8:15 pm
by Evgene Karachevtsev

Hello Michael,

1) [quote:]if(value === undefined){ return "; } to the label marked in the screenshot and it returns all nothing.at[/quote]
You return the empty string if the value is not defined. Empty string displays.
2) Could you please check that you have the correct structure of response?


mapping problem returning undefined

Posted: Thu Jul 24, 2014 7:08 am
by Michael4771079

Hi,
I cannot figure this out, its daft
I need to read an entry in a collection using _id,
the correct _id is in local storage, the service fine runs in test tab, but I am getting an error,
everything looks to be set up OK so plwase take a look at these screenshots and tell me if you can see my mistake, cause I cant find it
sorry for all the s/shots, thought it may be easier

thx

Image

Image
Image
Image
Image
Image
Image
Image


mapping problem returning undefined

Posted: Thu Jul 24, 2014 12:32 pm
by Evgene Karachevtsev

Hello Michael,

Please remove the slashes before the quotation marks:
pre{"Explained":"53d0a974e4b0c0039baab"}/pre


mapping problem returning undefined

Posted: Thu Jul 24, 2014 1:47 pm
by Michael4771079

sorry Evgene,
I dont follow, I see slashes in the error, where do I remove them from


mapping problem returning undefined

Posted: Thu Jul 24, 2014 1:50 pm
by Evgene Karachevtsev

Michael,

Oh, I'm sorry, this is how it looks correctly:
pre{"_id":"53d0a974e4b0c0039baab"}/pre


mapping problem returning undefined

Posted: Thu Jul 24, 2014 2:21 pm
by Michael4771079

Evgene, the only place I see slashes is in the url, remove any and the service doesnt work, unless I'm having another blond day and am missing something :)


mapping problem returning undefined

Posted: Thu Jul 24, 2014 7:14 pm
by Michael4771079

any ideas Evgene?
going bald again


mapping problem returning undefined

Posted: Thu Jul 24, 2014 7:38 pm
by Evgene Karachevtsev

Michael,

According to your first screenshot wrong _id is passed to request parameter of _id service
You pass a string

{"_id":"53d0a974e4b0c0039baab"}

but you should pass

53d0a974e4b0c0039baab


mapping problem returning undefined

Posted: Thu Jul 24, 2014 8:28 pm
by Michael4771079

your correct, this code in mapping returns the
error with slashes, delete the code the response is undefined,

return '{"_id": "' + value + '"}';

in another app easilet I use this same procedure and service to pull a properties details using _id with no mapping code which works perfectly, however there are no arrays in the collection