I have asked to connected to Duffel API, and I have the token access to there database in order to use it in my project.
Below is the JavaScript they used
yarn add @ duffel / api
import { Duffel } from ‘@duffel/api’
const duffel = new Duffel ({
token : YOUR_ACCESS_TOKEN
})
Since no yarn in Velo I modify it as follow
// using wix fetch code below
import { fetch } from ‘wix-fetch’ ;
// …
fetch ( “Overview<!-- --> | Duffel Documentation” , { “method” : “get” })
. then (( httpResponse ) => {
let url = httpResponse . url ;
let statusCode = httpResponse . status ;
let statusText = httpResponse . statusText ;
let headers = httpResponse . headers ;
let bodyUsed = httpResponse . bodyUsed ;
if ( httpResponse . ok ) {
return httpResponse . json ();
} else {
return Promise . reject ( “Fetch did not succeed” );
}
})
. then (( json ) => {
console . log ( json . someKey );
})
. catch (( err ) => {
console . log ( err );
});
but it missing some extra code !
Velo npm modules are irrelevant for this part
there url is https://duffel.com/api
Could anyone please show me how to do it. Or send me an example to follow. Thank you in advance.