Skip to content

Commit

Permalink
Improve Bing search api params
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa-Esoofally committed Jun 12, 2024
1 parent 645940b commit 9c2f1cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.env
6 changes: 4 additions & 2 deletions app/api/getSources/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export async function POST(request: Request) {
const params = new URLSearchParams({
q: question,
mkt: "en-US",
count: "6",
safeSearch:"Strict"
});

const response = await fetch(
Expand All @@ -21,10 +23,10 @@ export async function POST(request: Request) {
const bingJson = await response.json();
const bingResults = bingJson.webPages.value;

const firstSixResults = bingResults.slice(0, 6).map((result: any) => ({
const Results = bingResults.map((result: any) => ({
name: result.name,
url: result.url,
}));

return NextResponse.json(firstSixResults);
return NextResponse.json(Results);
}

0 comments on commit 9c2f1cd

Please sign in to comment.