GET http://localhost:8000/api/rajaongkir/search-destinationCopy URL
curl PowerShell JavaScript Node.js Python Go PHP Copy
curl --request GET \
--url http://localhost:8000/api/rajaongkir/search-destination $ response = Invoke-WebRequest - Uri ' http://localhost:8000/api/rajaongkir/search-destination ' - Method GET const url = ' http://localhost:8000/api/rajaongkir/search-destination ' ;
const options = { method : ' GET ' };
try {
const response = await fetch ( url , options );
const data = await response . json ();
console . log ( data );
} catch ( error ) {
console . error ( error );
} const fetch = require ( ' node-fetch ' );
const url = ' http://localhost:8000/api/rajaongkir/search-destination ' ;
const options = { method : ' GET ' };
try {
const response = await fetch ( url , options );
const data = await response . json ();
console . log ( data );
} catch ( error ) {
console . error ( error );
} import requests
url = " http://localhost:8000/api/rajaongkir/search-destination "
response = requests . get ( url )
print ( response . json ()) package main
import (
" fmt "
" net/http "
" io "
)
func main () {
url := " http://localhost:8000/api/rajaongkir/search-destination "
req , _ := http . NewRequest ( " GET " , url , nil )
res , _ := http . DefaultClient . Do ( req )
defer res . Body . Close ()
body , _ := io . ReadAll ( res . Body )
fmt . Println ( res )
fmt . Println ( string ( body ))
} <? php
$ curl = curl_init ();
curl_setopt_array ($ curl , [
CURLOPT_PORT => " 8000 " ,
CURLOPT_URL => " http://localhost:8000/api/rajaongkir/search-destination " ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_ENCODING => "" ,
CURLOPT_MAXREDIRS => 10 ,
CURLOPT_TIMEOUT => 30 ,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
CURLOPT_CUSTOMREQUEST => " GET " ,
]);
$ response = curl_exec ($ curl );
$ err = curl_error ($ curl );
curl_close ($ curl );
if ($ err ) {
echo " cURL Error #: " . $ err ;
} else {
echo $ response ;
}
Controller meneruskan hasil provider dan membatasi pencarian provider dengan limit 15 serta offset 0.
POST http://localhost:8000/api/rajaongkir/calculate-shippingCopy URL
curl PowerShell JavaScript Node.js Python Go PHP Copy
curl --request POST \
--url http://localhost:8000/api/rajaongkir/calculate-shipping $ response = Invoke-WebRequest - Uri ' http://localhost:8000/api/rajaongkir/calculate-shipping ' - Method POST const url = ' http://localhost:8000/api/rajaongkir/calculate-shipping ' ;
const options = { method : ' POST ' };
try {
const response = await fetch ( url , options );
const data = await response . json ();
console . log ( data );
} catch ( error ) {
console . error ( error );
} const fetch = require ( ' node-fetch ' );
const url = ' http://localhost:8000/api/rajaongkir/calculate-shipping ' ;
const options = { method : ' POST ' };
try {
const response = await fetch ( url , options );
const data = await response . json ();
console . log ( data );
} catch ( error ) {
console . error ( error );
} import requests
url = " http://localhost:8000/api/rajaongkir/calculate-shipping "
response = requests . post ( url )
print ( response . json ()) package main
import (
" fmt "
" net/http "
" io "
)
func main () {
url := " http://localhost:8000/api/rajaongkir/calculate-shipping "
req , _ := http . NewRequest ( " POST " , url , nil )
res , _ := http . DefaultClient . Do ( req )
defer res . Body . Close ()
body , _ := io . ReadAll ( res . Body )
fmt . Println ( res )
fmt . Println ( string ( body ))
} <? php
$ curl = curl_init ();
curl_setopt_array ($ curl , [
CURLOPT_PORT => " 8000 " ,
CURLOPT_URL => " http://localhost:8000/api/rajaongkir/calculate-shipping " ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_ENCODING => "" ,
CURLOPT_MAXREDIRS => 10 ,
CURLOPT_TIMEOUT => 30 ,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
CURLOPT_CUSTOMREQUEST => " POST " ,
]);
$ response = curl_exec ($ curl );
$ err = curl_error ($ curl );
curl_close ($ curl );
if ($ err ) {
echo " cURL Error #: " . $ err ;
} else {
echo $ response ;
}
Weight dibulatkan ke atas sebelum dikirim ke provider.
Toko Digital memanggil provider shipping dari controller. Credential provider harus berada di secret configuration, bukan source. Source saat ini memiliki risiko TLS verification yang dinonaktifkan; jangan menganggap koneksi provider sudah aman tanpa audit.
Controller mengembalikan hasil decode provider. Consumer frontend perlu menangani response kosong, error provider, tujuan tanpa postal code, dan courier yang tidak tersedia.