question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not passing multiple custom fields

See original GitHub issue

Seems to only pass the last custom field passed to customFields.

ie:

let parser = new Parser({
    customFields: {
      item: ['s:type','s:type'], 
      item: ['s:vendor','s:vendor']
      item: ['summary','summary'],
      //item: ['s:tag','s:tag'],
      //item: ['s:variant','s:variant', {keepArray: true}] //<---

    }
  });
   
  parser.parseURL('https://kith.com/collections/all/products.atom', function(err, feed) {
    //console.log(feed.extendedDescription);

if(!err){
    feed.items.forEach(function(entry) {
        //console.log(entry['s:type']);
        //console.log(entry['s:vendor']);
        console.log(entry.summary);
        //console.log(entry['s:tag']);
        //console.log(entry['s:variant']);
        //console.log(entry);
        
    });
    //console.log(feed.items[7]['s:type']);
    //console.log(feed.items[7]['s:vendor']);
    console.log(feed.items[7]['summary']);
    //console.log(feed.items[7]['s:tag']);
    //console.log(feed.items[5]['s:variant']['s:price'][0]['_']);
    //console.log(feed.items[5].summary);
   }else{
       console.log(err.message);
   };

Seems to only pass THE LAST item added to “customFields”. ‘s:vendor’ will show undefined untill “item: [‘summary’,‘summary’],” is commented out then it will work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
rbrencommented, Dec 23, 2018

You syntax isn’t quite right:

let parser = new Parser({
    customFields: {
      item: [
        ['s:type','s:type'], 
        ['s:vendor','s:vendor']
        ['summary','summary'],
        ['s:tag','s:tag'],
        ['s:variant','s:variant', {keepArray: true}] //<---
    }
  });

And since you’re not trying to rename fields, it can be even simpler:

let parser = new Parser({
    customFields: {
      item: [
        's:type', 
        's:vendor',
        'summary',
        's:tag',
        ['s:variant','s:variant', {keepArray: true}],
      ]
    }
});
1reaction
rbrencommented, Dec 23, 2018

(Also note that your input above, which has multiple item fields, isn’t really a valid JS object - in JS, you can only specify one value per key).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Custom Fields - Anuko Forums
I would like to have more than one custom field available. I started using a custom field in order to add a different...
Read more >
How to pass multiple custom fields as shortcode's parameters
And here is the code I built to call shortcode with parameters, but I only know pass 1 custom fields at one time....
Read more >
Cannot create multiple custom fields using Metadata API
Hi all,. I can successfully connect to the Metadata API and create a custom field, but what I would like to do is...
Read more >
How to pass multiple values to custom fields using campaign ...
You need to create "Custom fields"(on right sidebar) from your listid. Ex(Subject,Phone Number,Suburb,Message etc). When you export the ...
Read more >
Setting multiple values in multi_enum custom fields
I'm attempting to create tasks via the /tasks endpoint and want to set multiple values in a custom multi_enum field.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found