Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Function parameters as JSON key in Node.js

Topic Labels: API
Solved
Jump to Solution
1932 2
cancel
Showing results for 
Search instead for 
Did you mean: 
RSk
6 - Interface Innovator
6 - Interface Innovator

Hello, How do I pass function parameters as JSON field name for updating fields in Airtable using Airtable REST API and Node.js?

The code

const updateField = async (id, field_name, updateValue) => {

  base('table_name').update([
    {
      "id": id,
      "fields": {
        field_name: updateValue
      }
    }
  ], function (err, records) {
    if (err) {
      console.error(err);
      return;
    }
  });
}
1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

Is this what you need?
[field_name]: updateValue

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

Is this what you need?
[field_name]: updateValue

RSk
6 - Interface Innovator
6 - Interface Innovator

Works!
Thank you for pointing out the silly mistake!