问题描述
嗨,因为我是新手,这个问题可能很小,但我找不到任何解决方案。
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从一组数字中发送不同的电话号码?
解决方法
你可以这样做:
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)
})