Path: blob/master/cloud/ai-service-apps/nextjs-carbon-react-ui/src/app/api/deployment/route.js
6410 views
import { NextResponse } from "next/server";1import { URLS, getToken } from "../../lib/util";23export async function GET() {4try {5const token = await getToken();67const options = {8method: "GET",9headers: {10Authorization: `Bearer ${token}`,11Accept: "application/json",12},13};1415const response = await fetch(URLS.deploymentUrl, options);1617if (!response.ok) {18throw new Error("Unexpected response from get-deployment: " + (await response.text()));19}20const result = await response.json();21const fields = {22name: result.entity.name,23description: result.entity.description,24avatar_color: result.entity.custom?.avatar_color,25avatar_icon: result.entity.custom?.avatar_icon,26placeholder_image: result.entity.custom?.placeholder_image,27sample_questions: result.entity.custom?.sample_questions,28};29return NextResponse.json(fields);30} catch (err) {31console.error(err);32return NextResponse.json({ error: err.message }, { status: 500 });33}34}353637