In my meteor app , this code
var format = [];
var formats = [];
var length = result.formats.length - 1;
for (var i = 0 ; i <= length; i++) {
var type = result.formats[i].type;
var type2 = type.split(/[;,]/);
var typee = type2[0];
var resolutions = result.formats[i].resolution;
var urls = result.formats[i].url;
format.push({
"Type": typee,
"resolution": resolutions
// "url": urls
})
};
var formatt = JSON.stringify(format, null, 4);
Session.set('format', JSON.stringify(format, null, 4));
console.log(formatt);
give me this result
[
{
"Type": "video/webm",
"resolution": "360p"
},
{
"Type": "video/mp4",
"resolution": "360p"
},
{
"Type": "video/x-flv",
"resolution": "240p"
},
{
"Type": "video/3gpp",
"resolution": "240p"
},
{
"Type": "video/3gpp",
"resolution": "144p"
},
{
"Type": "video/mp4",
"resolution": "360p"
},
{
"Type": "video/webm",
"resolution": "360p"
},
{
"Type": "video/mp4",
"resolution": "240p"
},
{
"Type": "video/webm",
"resolution": "240p"
},
{
"Type": "video/mp4",
"resolution": "144p"
},
{
"Type": "video/webm",
"resolution": "144p"
},
{
"Type": "audio/webm",
"resolution": null
},
{
"Type": "audio/mp4",
"resolution": null
},
{
"Type": "audio/webm",
"resolution": null
},
{
"Type": "audio/webm",
"resolution": null
},
{
"Type": "audio/webm",
"resolution": null
} ]
How can I do to get only the values without parentheses; something like that
"Type": "video/webm",
"resolution": "360p"
"Type": "video/mp4",
"resolution": "360p"
"Type": "video/x-flv",
"resolution": "240p"
"Type": "video/3gpp",
"resolution": "240p"
"Type": "video/3gpp",
"resolution": "144p"
"Type": "video/mp4",
"resolution": "360p"
"Type": "video/webm",
"resolution": "360p"
"Type": "video/mp4",
"resolution": "240p"
"Type": "video/webm",
"resolution": "240p"
"Type": "video/mp4",
"resolution": "144p"
"Type": "video/webm",
"resolution": "144p"
"Type": "audio/webm",
"resolution": null
"Type": "audio/mp4",
"resolution": null
"Type": "audio/webm",
"resolution": null
"Type": "audio/webm",
"resolution": null
"Type": "audio/webm",
"resolution": null
I spent two days without solution :(
Thank's for you help
Edit: what I want to do is to retrieve an array of values or cursors used in {{#each}} in a template
{#each format}}
<tr>
{{> postItem}}
</tr>
{{/each}}
<template name="postItem">
{{Type}}
{{resolution}}
{{url}}
</template>
Template.hello.helpers({
format:function(){
return Session.get('format');
}
});