Moe
Posts: 0
Joined: Thu Jul 10, 2014 9:24 pm

Assign default value to mapping only if response is empty

I have an API request that returns what should be visible on the page, it works great. My question is if nothing is returned, how do I set a default?

Image

Vinny B
Posts: 0
Joined: Fri Aug 22, 2014 2:22 pm

Assign default value to mapping only if response is empty

Does this help? I use it in mapping click the green js

var tweet = value;
var boro = tweet.substring(0, 7);
if (boro === 'MAN ALL') {
output = '"0"';
}
else if (boro === 'BKLYN A') {
output = '"9"';
}
else if (boro === 'BX ALL ') {
output = '"8"';
}
else if (boro === 'QNS ALL') {
output = '"7"';
}
else if (boro === 'SI ALL ') {
output = '"6"';
}
else if (boro === 'MAN 2-A') {
output = '"5"';
}
else if (boro === 'BKLYN 2') {
output = '"4"';
}
else if (boro === 'BX 2-AL') {
output = '"3"';
}
else if (boro === 'QNS 2-A') {
output = '"2"';
}
else if (boro === 'SI 2-AL') {
output = '"1"';
}

return output;

Moe
Posts: 0
Joined: Thu Jul 10, 2014 9:24 pm

Assign default value to mapping only if response is empty

Thanks so much, I didn't realize that the var value was what being passed.

Return to “Issues”