Call the backend API in batch to add objects, but check whether there are duplicate values one by one before adding them. How to write promise?

vue.js environment, you need to fill in multiple objects on the page and add them to the backend in batches. Currently, there are two APIs in api.js:
apiCheckDuplicated (name)
apiCreateNew (name)
ajax calls implemented by axios.

now the page has entered a bunch of new name: interactively

var newnames = xxxxxx []

first, the for loop detects whether it exists one by one, displays what already exists, reminds the user that it cannot be submitted, and then submits the calling interfaces that do not exist one by one. I"m going to write it in promise, but it feels like it"s too complicated to use. Who can give me an example?

Mar.10,2021

Logic improvement:
1. Triggers a check for duplicate API when the text box blur. If you repeat, directly remind the user to repeat, re-fill in;
2. Instead of circular calling the interface to pass a single name, write it as an object / array, etc., and submit all the data at once

Menu