Skip to content

Commit

Permalink
check if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
fredolss committed Apr 23, 2018
1 parent 036b631 commit dc8a811
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions hyperjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,13 @@ var BaseResource = (function () {
if (typeof customOptions.method != "undefined") {
options.method = customOptions.method;
}
for (key in customOptions.headers) {
options.headers[key] = customOptions.headers[key];
if (customOptions.headers) {
if (typeof options.headers === "undefined") {
options.headers = {};
}
for (key in customOptions.headers) {
options.headers[key] = customOptions.headers[key];
}
}
}
return [4, HttpClient_1.request(options)];
Expand Down
10 changes: 5 additions & 5 deletions src/HyperJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export interface Resource < TData = any > {
}

interface InternalResourceBuilder extends ResourceBuilder {
getSelf:(data:any) => string;
getLink:(rel:string, data:any) => string;
getRequestOptions:(resource:Resource,options:RequestOptions) => RequestOptions;
getSelf:getSelf;
getLink:getLink;
getRequestOptions:getRequestOptions;
}

type getRequestOptions = (resource:Resource,options:RequestOptions) => CustomRequestOptions;
Expand All @@ -42,8 +42,8 @@ type getSelf = (data:any) => string;
export interface CustomRequestOptions {
method?:string,
url?:string,
data?:string | object,
headers?:object,
data?:any,
headers?:any,
contentType?:string;
}

Expand Down

0 comments on commit dc8a811

Please sign in to comment.