1
const response = await fetch(API_URL, {
    method: 'POST',
    body: JSON.stringify(body),
    headers: headers
})

Here API_URL = ​https://139.59.39.54:53724/business/1.0/verify

Getting error

TypeError: Only absolute URLs are supported

I though maybe the problem with package it doesn't support domain with IP addresses, so I also tried nip.io .

But still getting same error.

Update

I am using dotenv for environment variables. So If directly use the domain I don't get error any more.

const response = await fetch("​https://139.59.39.54:53724/business/1.0/verify", {
     method: 'POST',
     body: JSON.stringify(body),
     headers: headers
})
Ha. Huynh
  • 1,772
  • 11
  • 27
sujeet
  • 3,480
  • 3
  • 28
  • 60

1 Answers1

0

I think you're missing reading environment variables with dotenv, such as call require('dotenv').config();.

Because dotenv can understand API_URL = ​https://139.59.39.54:53724/business/1.0/verify that API_URL is a string. Therefore API_URL you read from process.env.API_URL now is empty, which can cause the error.

Please make sure you've called require('dotenv').config(); before reading process.env.API_URL.

Ha. Huynh
  • 1,772
  • 11
  • 27