The code below result in Math.random() always returning the same number, on each request. Moving the constant requestId in to the handler function resolves it, so that Math.random() now returs a new number on each request.
import { HandleRequest, HttpRequest, HttpResponse } from "@fermyon/spin-sdk"
import { v4 as uuidv4 } from "uuid";
// Moving this inside the handler will solve the problem
const requestId = uuidv4()
export const handleRequest: HandleRequest = async function (request: HttpRequest): Promise<HttpResponse> {
let number = Math.floor(Math.random() * 10)
console.log(number)
return {
status: 200,
headers: { "content-type": "text/plain" },
body: JSON.stringify(number)
}
}