File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 1+ import ApiRequestError from '../error/api_request_error.ts' ;
2+ import FetchRequestError from '../error/fetch_request_error.ts' ;
13import { DnsRecord } from '../record/dns_record.ts' ;
24import { ApiRequestOptions } from './api_request_options.ts' ;
35
46export default function updateDnsRecord (
57 record : DnsRecord ,
68 options : ApiRequestOptions
79) : void {
8-
10+ fetch (
11+ `${ options . apiEndpoint } zones/${ options . zoneId } /dns_records/${ options . recordId } ` ,
12+ {
13+ method : 'PATCH' ,
14+ headers : {
15+ 'Content-Type' : 'application/json' ,
16+ 'Authorization' : `Bearer ${ options . token } `
17+ } ,
18+ body : JSON . stringify ( record )
19+ }
20+ )
21+ . then ( ( response ) => {
22+ if ( response . ok ) {
23+ return response . json ( ) ;
24+ }
25+ throw new FetchRequestError ( { cause : response . statusText } ) ;
26+ } )
27+ . then ( ( responseJson ) => {
28+ if ( ! responseJson . success ) {
29+ throw new ApiRequestError ( { cause : responseJson . errors } )
30+ }
31+ } ) ;
932}
You can’t perform that action at this time.
0 commit comments