Skip to content

Commit 9c2f1cd

Browse files
Improve Bing search api params
1 parent 645940b commit 9c2f1cd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
.env

app/api/getSources/route.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export async function POST(request: Request) {
55
const params = new URLSearchParams({
66
q: question,
77
mkt: "en-US",
8+
count: "6",
9+
safeSearch:"Strict"
810
});
911

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

24-
const firstSixResults = bingResults.slice(0, 6).map((result: any) => ({
26+
const Results = bingResults.map((result: any) => ({
2527
name: result.name,
2628
url: result.url,
2729
}));
2830

29-
return NextResponse.json(firstSixResults);
31+
return NextResponse.json(Results);
3032
}

0 commit comments

Comments
 (0)