title: PHP Error with array_merge(): Expected parameter 2 to be an array, null given
body: <p>I'm trying to make a http post request to my Laravel API from Ionic 4.
  I've made other Post successfully before with the same API.
  But for some reason I can't make this one work.</p>
  
  <p>The method on the Laravel backend receives an ID and then sends a email with a PDF attached.</p>
  
  <p>I've test it with Postman tool and it works fine. But when I test on the Ionic 4 App it doesn't work.</p>
  
  <p>I tried changing the headers with different options without luck.</p>
  
  <p>I have set the CORS on Laravel backend like this:</p>
  
  <pre><code>header('Access-Control-Allow-Origin: *');
  header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Authorization");
  header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
  header("Allow: GET, POST, OPTIONS, PUT, DELETE");
  $method = $_SERVER['REQUEST_METHOD'];
  if($method == "OPTIONS") {
      die();
  }
  </code></pre>
  
  <p>On Postman it works as expected:
  <a href="https://i.imgur.com/sNuJCzK.png" rel="nofollow noreferrer">https://i.imgur.com/sNuJCzK.png</a>
  <a href="https://i.imgur.com/ZgLJA20.png" rel="nofollow noreferrer">https://i.imgur.com/ZgLJA20.png</a></p>
  
  <p>This is my <strong>Player.service.ts</strong>:</p>
  
  <pre><code>    pdf(idPlayer): Observable&lt;any&gt; {
  
        let json = {
                idplayer : idPlayer
        };
  
        let params = "json=" + JSON.stringify(json);
  
         const httpOptions = {
           headers: new HttpHeaders({
              'Accept': 'application/json',
              'Authorization' : localStorage.getItem("token"),
              'Content-Type' : 'application/x-www-form-urlencoded',
           })
         };
  
         console.log("PDF PARAMS:");
         console.log(params);
  
        return this._http.post('http://127.0.0.1:8000/api/pdf/email', params, httpOptions);
      }
  </code></pre>
  
  <p>This is the function that calls the service on my <strong>Tab-Profile.page.ts</strong>:</p>
  
  <pre><code>    enviarPdf() {
        this._playerService.pdf(this.player._id).subscribe(
          response =&gt; {
            console.log("SEND PDF:");
            console.log(response);
          },
          error =&gt; {
            console.log("error sendPDF:");
            console.log(error);
          });
      }
  </code></pre>
  
  <p>This is the error on Chrome console:</p>
  
  <p><a href="https://i.stack.imgur.com/FVQUy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FVQUy.png" alt="Chrome error message"></a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is my php function in <strong>PlayerController.php</strong>:</p>
  
  <pre><code>    public function ToPdf(Request $request) {
  
        // Obtener usuario identificado
        $token = $request-&gt;header('Authorization');
        $jwtAuth = new \JwtAuth();
        $checkToken = $jwtAuth-&gt;checkToken($token);
  
        $user = $jwtAuth-&gt;checkToken($token, true);
  
        $json = $request-&gt;input('json', null);
        $params_array = json_decode($json, true);
  
        $id_player = $params_array['idplayer'];
  
        $player = Player::find($id_player);
  
        $pdf = PDF::loadView('templatePdf', $player);
  
        $pdf_name = $player-&gt;id . '.pdf';
  
        $content = $pdf-&gt;output();
  
        \Storage::disk('players')-&gt;put('/pdf/' . $pdf_name, $content);
  
        $exists = \Storage::disk('player')-&gt;exists('/pdf/' . $pdf_name);
  
        if (!$exists) {
          $data = array(
            'code' =&gt; 400,
            'status' =&gt; 'error',
            'message' =&gt; 'Error PDF.',
            'pdf' =&gt; $pdf_name
          );
        }
        else {
          $email_params = array(
            'userName' =&gt; $user-&gt;name,
            'playerId' =&gt; $player-&gt;id,
            'playerName' =&gt; $player-&gt;name,
            'playerSurname' =&gt; $player-&gt;surname,
          );
  
          // Mail::to($user-&gt;email)-&gt;queue(new EmailPdf($email_params));
          Mail::to($user-&gt;email)-&gt;queue(new EmailPdf($email_params));
  
          \Storage::disk('players')-&gt;delete('/pdf/' . $pdf_name);
  
          $data = array(
            'code' =&gt; 200,
            'status' =&gt; 'success',
            'message' =&gt; 'Email sended successfully.',
          );
        }
  
        return response()-&gt;json($data, $data['code']);
  
      }
  </code></pre>