0

When I do a console.log on the variable event.body it shows article_url=http%3A%2F%2Fow.ly%2Fjo2n30fdI3y

How can I access the value of article_url In other words, I want to access http%3A%2F%2Fow.ly%2Fjo2n30fdI3y

asked Sep 19, 2017 at 15:37
2
  • Where is this coming from? Is it like a url query? Commented Sep 19, 2017 at 15:39
  • What have you tried? Where is your code? Commented Sep 19, 2017 at 15:39

3 Answers 3

1

If you actually want to decode the percent encoded characters too, the best way is to use the native node.js querystring module:

const body = require( 'querystring' ).parse( event.body );
const article_url = body.article_url; 
console.log( article_url );
answered Sep 19, 2017 at 15:41
Sign up to request clarification or add additional context in comments.

Comments

0
console.log(event.body.split('=')[1])
answered Sep 19, 2017 at 15:38

Comments

0

Simplest approach is probably the following:

var input = "article_url=http%3A%2F%2Fow.ly%2Fjo2n30fdI3y";
var output = input.split("=")[1];
console.log(output) // "http%3A%2F%2Fow.ly%2Fjo2n30fdI3y"

answered Sep 19, 2017 at 15:38

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.