I don't really need to provide a script for this, but here's an example:
1 | url = "url.com" |
2 | http = game.HttpService |
3 |
4 | if not http:GetAsync(url) then |
5 | print ( "invalid!" ) |
6 | else |
7 | print ( "valid!" ) |
you get the point. My problem is that whatever way i try and do this, it always returns a http not found (404) even if i'm using 'if not'. Would there be any way to detect an invalid url?
thanks!
After messaging Seranok, he told me:
There is currently no way to check the status code of the response. At some point in the future we may add this functionality but not in the foreseeable future. If you want to handle errors you can use pcall.
To use pcall, do this:
01 | function getData() |
02 | --request here |
03 | return --return the response |
04 | end |
05 | success, responseBody = pcall (getData) |
06 | if success then |
07 | --do something with responseBody |
08 | else |
09 | print ( "There was an error" ) |
10 | end |
From what I'm getting out of what you're asking, the easiest way it seems to do this, would be to search for 404 on the page, and if it's there, then it prints "Invalid!" Hope this helped. If not feel free to keep asking me for help until we solve your problem so it does work.