Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rum-core/src/common/patching/fetch-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function patchFetch(callback) {
url = input
}
} else if (input) {
request = input
request = init ? new Request(input, init) : input
url = request.url
} else {
return nativeFetch.apply(fetchSelf, args)
Expand Down
17 changes: 17 additions & 0 deletions packages/rum-core/test/common/fetch-patch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ describe('fetchPatch', function () {
})
})

it('should fetch correctly when using REQUEST object as input with options', function (done) {
var fetchArgs = createFetchArgs('PATCH')
var newFetchArgs = createFetchArgs('POST')
var promise = window.fetch(
new Request(fetchArgs.url, fetchArgs.options),
newFetchArgs.options
)

expect(typeof promise.then).toBe('function')
expect(events.map(e => e.event)).toEqual(['schedule'])

// Validate that fetch has been called with the proper data
const data = events[0].task.data
validateFetchData(data, newFetchArgs)
done()
})

it('should produce task events when fetch fails', function (done) {
var promise = window.fetch('http://localhost:54321/')
promise.catch(function (error) {
Expand Down
Loading