Using Codeigniter as RestAPI (using Axios) |
Hello, I'm trying to use Codeigniter 4 as a RestAPI, but I'm encountering an high number of problems. Some of them are strangely omitted in the docs (and I can't search in the forum because there's a bug in the search at the moment).
I'm using Axios to contact the server. 1) How does validate() work? I can't find the details in the docs and I can't understand what data validates and if there's a way to submit custom data to validate (and I need this really hard) 2) I can't work with axios.put. For some reason it doesn't populate the $_POST correctly. - If I send a JSON with 'Content-Type': 'application/json' , php://input has the JSON but $this->request->getRawInput() give me this: $varname[{"lorem":"ipsum"}] => null - If I send a FormData, I get this monstrosity: [------WebKitFormBoundarygAazo6HBmB477LPA Content-Disposition:_form-data;_name] => "lorem" 3) to do some tests with localhost to real server I had to add some extra junk code because header('Access-Control-Allow-Origin: *'); in the public/index.php doesn't work alone. I need to use $this->response->setHeader in the Control too. P.S: My code is a total mess of tests, I don't really have something to show. |
Messages In This Thread |
Using Codeigniter as RestAPI (using Axios) - by shinseiten - 10-01-2020, 03:04 AM
RE: Using Codeigniter as RestAPI (using Axios) - by nc03061981 - 10-04-2020, 01:49 AM
RE: Using Codeigniter as RestAPI (using Axios) - by shinseiten - 10-12-2020, 03:08 PM
RE: Using Codeigniter as RestAPI (using Axios) - by connectgrid - 10-13-2020, 06:17 AM
RE: Using Codeigniter as RestAPI (using Axios) - by shinseiten - 10-14-2020, 07:26 AM
RE: Using Codeigniter as RestAPI (using Axios) - by nicojmb - 10-14-2020, 01:03 PM
|