2

I'm unsure how to approach this problem. I have input and it needs to take a URL and the user can put in as many URLs as they want.

For example:

<input 
  type="text"  
  v-model="fields.urls" 
  class="form-control" 
  id="basic-url"
  aria-describedby="basic-addon3">

I need to pass an array of URLs to the backend like this:

 ['firsturl', 'secondurl', ...]
1
  • How does the user type URLs? Are they just comma separated values or..? What have you tried to fix this? Commented Mar 12, 2021 at 17:59

1 Answer 1

3

It's a better idea to ask for a string of all URLs and convert it into an array.

This will produce an array of URLs out of a comma-separated string.

// field.urls = google.com, amazon.com, stackoverflow.com
let urls = fields.urls.split(',').map(x => x.trim())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.