Hi there !
I'm trying to request an API to get suggested queries from a list of queries.
To do so, I'm using For Loop in order to iterate for every keyword in my list.
But I'm missing out something because it is only requesting the first and last keyword from my list (Results from the 2nd one may be erased during for loop).
Can someone help me here ?
Thanks a lot !
keywords <- c("KW_1","KW_2","KW2")
json <- fromJSON(paste("https://www.xxxx.fr/xxxx/api/xxxx?query=",keywords[1],"",sep=""))
df <- json$keywords$label[]
df = as.data.frame(df)
df["kw"] = keywords[1]
for (i in length(keywords)){
json <- fromJSON(paste("https://www.xxxx.fr/xxxx/api/xxxx?query=",keywords[i],"",sep=""))
tmp <- (json$keywords$label[])
tmp = as.data.frame(tmp)
tmp['kw'] = keywords[i]
}```