Closed abhinavvsinhaa closed 3 years ago
which framework do you use? flask? django or node? check you have opened appropriate ports in the server
I'm using node and hosting it on Digital Ocean, don't know why it's not working in there, but absolutely smooth in localhost. Can you tell me what request do we need to make to the cowin api, so that I can cross check mine
let options = {
'method': 'GET',
'url': `https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=${row.pincode}&date=${day}`,
'headers': {
}
};
request(options, function (error, re) {
if (error) {
console.log('error in request',error)
}
else if(re) {
let data = JSON.parse(re.body);
console.log(data)
}
})
@kumaraswins
These API are geo fenced. It works only with Indian network . So make sure your digital ocean is hosted in Mumbai or Indian region.
it's in Bengaluru. Do you find any error within my code? Sometime it works fine on the server sometimes it doesn't with the same code.
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode=110001&date=17/05/2021',
'headers': {
'accept': 'application/json',
'Accept-Language': 'hi_IN'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Make sure it is in this format
Don't need to parse it with JSON.parse?
ya you were right, the time is showing Mon May 17 03.54 UTC 2021
issue sorted?
Hello @abhinav-sinhaa , why are you using Requests while they are already depricated(On maintenance), And try using some other alternatives, such as AXIOS
If so you want to access a geo-fenced public API, I have a workaround for this, You can the package CASSATA to proxy your server to your current location, I have tested this on HEROKU with an US server for this API. For now it only supports get requests, and no post requests are allowed. https://github.com/saran-surya/cassata
issue sorted?
No it's not sorted, since the api is geo-fenced, the server becomes unable to fetch the api, may be the issue is rising because of the server's internet connection as it is working completely fine in my local computer.
Important Notice,
If so you want to access a geo-fenced public API, I have a workaround for this, You can the package CASSATA to proxy your server to your current location, I have tested this on HEROKU with an US server for this API. For now it only supports get requests, and no post requests are allowed. https://github.com/saran-surya/cassata
Will try this today, and let you know if this works
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said,
Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said,
Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Working fine on localhost, will try it now on server! Any custom specification need to be defined on server or not?
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said, Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Working fine on localhost, will try it now on server! Any custom specification need to be defined on server or not?
No there are no specific configurations needed for production, you can access it the same way as you did in development, Make sure you only access public data 👍
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said, Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Working fine on localhost, will try it now on server! Any custom specification need to be defined on server or not?
No there are no specific configurations needed for production, you can access it the same way as you did in development, Make sure you only access public data 👍
Man thanks a tonnnn! You literally saved my life. I'm checking for some bugs, after that I'll tell you the final updates!!Thanks again @saran-surya
@saran-surya Thanks a lot it's working fine on the server.
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said, Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Working fine on localhost, will try it now on server! Any custom specification need to be defined on server or not?
No there are no specific configurations needed for production, you can access it the same way as you did in development, Make sure you only access public data 👍
Man thanks a tonnnn! You literally saved my life. I'm checking for some bugs, after that I'll tell you the final updates!!Thanks again @saran-surya
Whenever I close the proxyrouter it automatically disconnects. What's the solution for that?
Sure @abhinav-sinhaa, I currently have this working for my Node JS app in production, A Heroku Server in US. They are working fine. For now you can only do GET Requests, Kindly let me know if you face any issues. 🦄
It's showing proxy server is not connected!
You have to connect the client, only then the PROXY will be connected, if you are calling the functions right away, You have to add a buffer time to get you enough time to connect it, It is basically doing the small scale process of proxy servers, What it will do is it will use your IP to get the data that is restricted to a area, Also you have to persist the session to maintain contact, This is a small scale version of proxy servers as said, Kindly refer this section https://github.com/saran-surya/cassata#accessing-the-proxy-client-, You have to connect the proxy client and then access the data. This should help.
Working fine on localhost, will try it now on server! Any custom specification need to be defined on server or not?
No there are no specific configurations needed for production, you can access it the same way as you did in development, Make sure you only access public data 👍
Man thanks a tonnnn! You literally saved my life. I'm checking for some bugs, after that I'll tell you the final updates!!Thanks again @saran-surya
Whenever I close the proxyrouter it automatically disconnects. What's the solution for that?
Thanks a lot for the response, Yes you have to have the proxyrouter open, for the period of time you need the server to use the proxy, for security reasons, the connection between the proxy and the server will be disconnected on RELOAD / CLOSING the active proxyrouter session, Not mandatory that you should have that running top of your screen, you can have it running in the background also, As said a smaller version of proxy routers, thus as long as your local machine is connected to the internet, and connected to the proxyrouter, your connection will be persistant. 👍🏻
Kindly refer this.. Client connection
Thank you again for help @saran-surya @kumaraswins . Now the issue is resolved so I'm closing it.
whenever i am trying to call the api from my server, its showing this error undefined:1 unexpected token < in json at position 0, while it is working completely fine when I am calling it from my local host. please help me