Reputation: 33
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', ...]
Upvotes: 2
Views: 360
Reputation: 3411
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())
Upvotes: 3