Nutlope / roomGPT

Upload a photo of your room to generate your dream room with AI.
https://www.roomgpt.io/
MIT License
9.94k stars 1.33k forks source link

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

Open zkpgds opened 1 year ago

zkpgds commented 1 year ago

How to fix it ?

gaurav-goswami commented 1 year ago

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 commented 1 year ago

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

@gaurav-goswami I hope in you!

gaurav-goswami commented 1 year ago

@eporedieis no idea. 😅

eporedieis commented 1 year ago

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

gaurav-goswami commented 1 year ago

yep

germanao commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

zhao-binxiang commented 11 months ago

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