16 lines
380 B
JavaScript
16 lines
380 B
JavaScript
import axios from "axios";
|
|
import 'dotenv/config';
|
|
|
|
const API_KEY = process.env.TAVILY_API_KEY;
|
|
|
|
async function webSearch(query) {
|
|
const response = await axios.post("https://api.tavily.com/search",
|
|
{ query },
|
|
{ headers: { Authorization: `Bearer ${API_KEY}` } }
|
|
);
|
|
|
|
console.log(response.data.results);
|
|
}
|
|
|
|
webSearch("who is the current president of united states");
|