Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TypeError: Cannot read properties of undefined (reading 'get') #94

Open
zkpgds opened this issue Jun 20, 2023 · 11 comments
Open

error TypeError: Cannot read properties of undefined (reading 'get') #94

zkpgds opened this issue Jun 20, 2023 · 11 comments

Comments

@zkpgds
Copy link

zkpgds commented Jun 20, 2023

  • error TypeError: Cannot read properties of undefined (reading 'get')
    at POST (webpack-internal:///(sc_server)/./app/generate/route.ts:56:46)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:242:37)

How to fix it ?

@gaurav-goswami
Copy link

I am getting the same error. I was working on an issue, and getting this error. By doing some logs I found that the issue is with the startResponse function. When you try to log jsonStartResponse you will get this message :-

{ detail: 'The requested resource could not be found.', status: 404 }

So, this variable let endpointUrl = jsonStartResponse.urls.get; will store undefined in it.

And this variable (endpointUrl) is being used in the finalResponse function , that's why it is showing "Cannot read properties of undefined (reading 'get' )"

@zkpgds

@eporedieis
Copy link

Same here. Anyone has ideas on how to fix it and have roomGPT working?

@gaurav-goswami I hope in you!

@gaurav-goswami
Copy link

@eporedieis no idea. 😅

@eporedieis
Copy link

So we'll wait and hope in @Nutlope 🤞🏻

@gaurav-goswami
Copy link

yep

@germanao
Copy link

germanao commented Aug 1, 2023

Hello guys @eporedieis @gaurav-goswami ,

Could you check if your Replicate token still available? This error may happen after the free limit ends, and then you will receive a 4xx error because the API won't return the GET URL.

At the same time, looking for 404 return, would be interesting to replace the string URL for the last string URL in the template,

@eporedieis
Copy link

eporedieis commented Aug 23, 2023

I confirm @germanao , the token is ok. I never added a credit card on Replicate: could be this one the problem in your opinion? For first times - according to Replicate website - they don't ask a payment method.

@germanao
Copy link

Hello @eporedieis,

Yes, this code doesn't have much error handling, so some problem might be masked by other errors.

At the moment, two fre options are available for you to validate your code:

  1. Ceate a new replicate account and use the new Replicate api key. With this, you will be able to generate images during the free time of Replicate Key

  2. In the api/generate/route.ts, add the following mock code just above the line: "let startResponse = await fetch("https://api.replicate.com/v1/predictions..."

let jsonMock =
  {
    "output": [
      "https://pbxt.replicate.delivery/cJFvv0OCv97bFZllhDa8QWJ0xbD2P8F007fp5cHizl7eAZVRA/output_1.png",
      "https://pbxt.replicate.delivery/cJFvv0OCv97bFZllhDa8QWJ0xbD2P8F007fp5cHizl7eAZVRA/output_1.png"
    ],
  }
  
  let restoredImageMock = jsonMock.output;

  return NextResponse.json(
    restoredImageMock ? restoredImageMock : "Failed to restore image"
  );

// POST request to Replicate to start the image restoration generation process
let startResponse = await fetch("https://api.replicate.com/v1/predictions", {.........

I'm not responsible for the repository, but I'm happy to help

@millenniumbug-pixel
Copy link

Trying the first solution I have the same problem.

Trying the second one I obtain this message:
image

I inserted the replicate api in a file called "api.env". A tried as content of this file
REPLICATE_API_KEY=verylongapikey
After the fail, I tried using " char before and after the api key, and then ' char. Nothing happen. Without them I tried also
REPLICATE_API_KEY=verylongapikey NEXT_PUBLIC_UPLOAD_API_KEY=anotherverylongkey

Nothing worked.

Have you any other ideas? Thank you very much for your help @germanao

@eporedieis
Copy link

Sorry, the last message was from me. I created the second account for the new api key.

@zhao-binxiang
Copy link

zhao-binxiang commented Oct 17, 2023

Ok. I encountered the same and I think I just solved it.
There are a few things you should go through

  • Did you enter the API key in the .env file?
  • When you "npm run dev", did you wait till the terminal showing all pages are built like /generate/route and /dream/page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants