Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

mapping problem returning undefined

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?

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

mapping problem returning undefined

Hello Michael,

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

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

mapping problem returning undefined

Michael,

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

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

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 :)

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

any ideas Evgene?
going bald again

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

mapping problem returning undefined

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

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

mapping problem returning undefined

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

Return to “Issues”