0

嗨,因为我是新手,这个问题可能很小,但我找不到任何解决方案。

    axios.get('http://apilayer.net/api/validateaccess_key=******&number=14158586273&country_code=&format=1')
    .then(response=>{
        console.log(response.data);
    }).catch(error =>{
        console.log(error)
    })

现在我想做一个批量电话号码验证程序,我想每次通过 url 发送不同的号码,这些号码存储在一个数组中。如何设置动态参数以通过 url 从数字数组中发送不同的电话号码?

4

1 回答 1

0

你可以这样做:

const API_PATH = 'http://apilayer.net/api/';
const numbers = ['14158586273', '14158586274', '14158586275', ...]
const paramsData = {
    validateaccess_key: '******',
    number: numbers[0], // your desired number here
    country_code: 123,
    format: 1
}


axios.get(API_PATH, { params: paramsData })
  .then(response => {
    console.log(response.data);
  }).catch(error =>{
    console.log(error)
  })
于 2021-07-02T17:48:06.990 回答