Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

laravel send http post request json

use GuzzleHttpClient;
class yourController extends Controller {

    public function saveApiData()
    {
        $client = new Client();
        $res = $client->request('POST', 'https://url_to_the_api', [
            'form_params' => [
                'client_id' => 'test_id',
                'secret' => 'test_secret',
            ]
        ]);
        echo $res->getStatusCode();
        // 200
        echo $res->getHeader('content-type');
        // 'application/json; charset=utf8'
        echo $res->getBody();
        // {"type":"User"...'
}
Comment

laravel http send data json raw

$response = Http::contentType("text/plain")->send('POST','https://example.com', [
    'body' => 'FETCH....'
])->json();
Comment

PREVIOUS NEXT
Code Example
Javascript :: node.js express 
Javascript :: reactsj substring 
Javascript :: cookie clicker hack extension 
Javascript :: js loop trough map 
Javascript :: javascript Swapping Variables 
Javascript :: window load 
Javascript :: react-native navigation screen props 
Javascript :: change select value jquery 
Javascript :: string indexing in js 
Javascript :: find by array of ids mongoose 
Javascript :: javascript throw error inside then 
Javascript :: jquery div onload function 
Javascript :: copy text to clipboard reactjs 
Javascript :: javascript check for null variables 
Javascript :: if text exists in element using javascript 
Javascript :: js get file location 
Javascript :: react leaflet recenter map 
Javascript :: wait js 
Javascript :: set attribute javascript 
Javascript :: string to number 
Javascript :: remove undefined from object js 
Javascript :: Converting string to json object 
Javascript :: str replace javascript all 
Javascript :: detect click outside react component 
Javascript :: jquery select option by value 
Javascript :: use setstate in function component 
Javascript :: this element in javascript 
Javascript :: Node Sass version 7.0.0 is incompatible with ^4.0.0 
Javascript :: javascript array.find 
Javascript :: nuxt eslint prettier vetur 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =