Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

javascript - Edit words in Zapier

Im trying to reverse words in Zapier. For example "word"-->"drow".

I already looked for an app which I can connect with Zapier, however I didn't found something. Maybe someone else knows something?

From my understanding, this can be also done by Code (Javascript or Python). Due to the fact that I have not really knowledge about coding and the app code by Zapier.

I tried this already, but it looks like that I'm making mistakes. Here is an example picture I tried. zapier test

And the code:

var cname1 = inputData.cname1.substring();
reverseString('cname1');
function reverseString(str) {
 return str.split("").reverse().join("");
}

Can anyone help me with this topic?


editor note: after editing, Stackoverflow wouldn't let me re-save the original title: Reverse words with Code by Zapier (Javascript/Python). Not sure why.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue is you need to return an object from Code by Zapier steps. Try this instead:

const result = {};

Object.entries(inputData).forEach(([key, value]) => {
  if (value) {
    result[key] = value.split("").reverse().join("");
  } else {
    result[key] = 'EMPTY'; // so the key isn't lost; can remove this branch if you don't care
  }
});

return result

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...